Set qry string value based on radio btn selected

Discussion in 'ASP General' started by mikezx10@hotmail.com, Mar 21, 2010.

  1. Guest

    I have a page that i need to sort if the user selects the sort radio
    btn and then hit the link to reload the page.

    I want to pass a 1 in the querystring for sort if the rb is checked
    and no querystring if the rb isnt checked.

    How can i do this?
    also once the rb is selected when i click it a second time it doesnt
    unselect

    I just inherited a classic asp site and have 1 week experiance so all
    the help u can give apreciated

    Thanks!
    <%@ Language=VBScript %>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    </head>
    <body>
    <%
    dim sort, strSQL
    sort=Request.QueryString("sort")

    if sort=1 then
    strSQL = strSQL & "ORDER BY Date Desc"
    else
    strSQL = strSQL & "ORDER BY fName"
    end if
    %>

    <div id="SelFra" style="POSITION: absolute; WIDTH: 100%;">
    <table width ="100%" border="0" cellspacing="0" align="center" >
    <tr bgcolor="#aeaeae" >
    <td style="width:200px;">&nbsp;&nbsp;
    <input type="radio" name="rbSort" value="0"
    <% IF sort=1 then Response.Write "Checked" end if %> /
    >&nbsp;&nbsp;Sort by Account Size&nbsp;&nbsp;

    </td>
    <td>
    <a href="Default22.asp?sort=1" >Image</a>
    </td>
    </tr>
    </table>
    </div>
    </body>
    </html>
    , Mar 21, 2010
    #1
    1. Advertising

  2. Bob Barrows Guest

    wrote:
    > I have a page that i need to sort if the user selects the sort radio
    > btn and then hit the link to reload the page.
    >

    This is an ASP newsgroup dealing with question about server-side scripting,
    so finding someone to help with a client-side coding question would probably
    be easier if you posted it to a client-side scripting newsgroup like
    m.p.scripting.jscript or comp.lang.javascript

    Incidently, I think the term you were looking for is "submit the form"
    rather than "reload the page".


    --
    Microsoft MVP - ASP/ASP.NET - 2004-2007
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows, Mar 21, 2010
    #2
    1. Advertising

  3. Guest

    This is asp 3.0 code, that is server side is it not?
    what i am doing is changing the sql that will be executed if a radio
    button is select.



    On Mar 21, 10:22 am, "Bob Barrows" <> wrote:
    > wrote:
    > > I have a page that i need to sort if the user selects the sort radio
    > > btn and then hit the link to reload the page.

    >
    > This is an ASP newsgroup dealing with question about server-side scripting,
    > so finding someone to help with a client-side coding question would probably
    > be easier if you posted it to a client-side scripting newsgroup like
    > m.p.scripting.jscript or comp.lang.javascript
    >
    > Incidently, I think the term you were looking for is "submit the form"
    > rather than "reload the page".
    >
    > --
    > Microsoft MVP - ASP/ASP.NET - 2004-2007
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    , Mar 21, 2010
    #3
  4. Gazing into my crystal ball I observed writing in
    news::

    Please don't top post. Post corrected, see below:

    >
    >
    > On Mar 21, 10:22 am, "Bob Barrows" <> wrote:
    >> wrote:
    >> > I have a page that i need to sort if the user selects the sort
    >> > radio btn and then hit the link to reload the page.

    >>
    >> This is an ASP newsgroup dealing with question about server-side
    >> scriptin

    > g,
    >> so finding someone to help with a client-side coding question would
    >> proba

    > bly
    >> be easier if you posted it to a client-side scripting newsgroup like
    >> m.p.scripting.jscript or comp.lang.javascript
    >>
    >> Incidently, I think the term you were looking for is "submit the
    >> form" rather than "reload the page".
    >>

    >
    > This is asp 3.0 code, that is server side is it not?
    > what i am doing is changing the sql that will be executed if a radio
    > button is select.


    Yes, and no. You did not ask the right question, and did not really
    provide any server side code. You also have some markup problems that
    should be dealt with as well.

    <%@ Language=VBScript %> - this is server side, and really not
    necessary, although I do recommend placing most of the server side code
    before anything is output to the client.

    <html xmlns="http://www.w3.org/1999/xhtml">

    Why are you attempting to use XHTML? You would be much better off using
    HTML. Your doctype is incorrect - see an HTML group for the proper way
    to do it.

    <head>
    <title></title>

    No title? How is the user to be able to tell which page he or she is
    on? Especially, if the user needs to change tabs and come back?

    </head>
    <body>
    <%
    dim sort, strSQL
    sort=Request.QueryString("sort")

    This part really should be up at the top, before the HTML declaration.
    Much easier to debug later.

    if sort=1 then
    strSQL = strSQL & "ORDER BY Date Desc"
    else
    strSQL = strSQL & "ORDER BY fName"
    end if

    Understand that 1 is a number, and "1" is a character.
    Request.querystring, and request.form return a character, not a number,
    so this is going to fail.

    Where is your query? How can we possibly help you with your query if
    you don't provide it?

    %>

    I don't see a form element in the markup below. You need that in order
    for the information to go anywhere. I would say that the form should be
    self-submitting. So you need something like:
    <form method="get" action="<%=request.servervariables("script_name")%>">
    You could use the actual page name, but script name is a little more
    portable.

    <div id="SelFra" style="POSITION: absolute; WIDTH: 100%;">
    <table width ="100%" border="0" cellspacing="0" align="center" >
    <tr bgcolor="#aeaeae" >
    <td style="width:200px;">&nbsp;&nbsp;
    <input type="radio" name="rbSort" value="0"
    <% IF sort=1 then Response.Write "Checked" end if %> /
    >&nbsp;&nbsp;Sort by Account Size&nbsp;&nbsp;


    You are using XHTML, so it would have to be checked="checked", not
    Checked (attributes in XHTML are lower case, and cannot be empty),
    another reason it might fail in modern browsers.

    </td>
    <td>
    <a href="Default22.asp?sort=1" >Image</a>
    </td>

    So the radio button is for presentation only? You would be better off
    doing something with CSS than this.

    </tr>
    </table>
    </div>
    </body>
    </html>

    You would be better off not using tables for presentation. Tables are
    for tabular data, and are a nightmare to maintain, especailly when they
    are nested.

    The most important part here is what the server is receiving from the
    client. In this case you want to test for:

    if request.querystring("sort") = "1" then
    'do something
    else
    'do something else
    end if



    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Mar 21, 2010
    #4
  5. Bob Barrows Guest

    Some of it is. The part that you are asking about (using a radio button to
    set the querystring portion of a querystring) will have to occur entirely on
    the client. You would have the same question if your page's extension was
    ..htm and it did not contain any server-side code, would you not?

    Think of it this way: ASP is server-side technology whose sole purpose is to
    use information contained in the Request to generate html to be sent to the
    client. You can see the generated html by using your browser to view the
    source. Once the html is sent to the client, everything that occurs after
    that point is client-side programming and out of scope of this newsgroup.

    I am not intending this as a rebuke so there is no need for you to get
    defensive. I am simply trying to help you get the answer to your question in
    the most effective way possible.

    wrote:
    > This is asp 3.0 code, that is server side is it not?
    > what i am doing is changing the sql that will be executed if a radio
    > button is select.
    >
    >
    >
    > On Mar 21, 10:22 am, "Bob Barrows" <> wrote:
    >> wrote:
    >>> I have a page that i need to sort if the user selects the sort radio
    >>> btn and then hit the link to reload the page.

    >>
    >> This is an ASP newsgroup dealing with question about server-side
    >> scripting, so finding someone to help with a client-side coding
    >> question would probably be easier if you posted it to a client-side
    >> scripting newsgroup like m.p.scripting.jscript or
    >> comp.lang.javascript
    >>
    >> Incidently, I think the term you were looking for is "submit the
    >> form" rather than "reload the page".
    >>
    >> --
    >> Microsoft MVP - ASP/ASP.NET - 2004-2007
    >> Please reply to the newsgroup. This email account is my spam trap so
    >> I don't check it very often. If you must reply off-line, then remove
    >> the "NO SPAM"


    --
    Microsoft MVP - ASP/ASP.NET - 2004-2007
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows, Mar 21, 2010
    #5
  6. Guest

    Ok I have not read all the msg yet but this is my 1st post ever and
    also i inherited this code. so what is top posting?

    On Mar 21, 11:57 am, Adrienne Boswell <> wrote:
    > Gazing into my crystal ball I observed writing innews::
    >
    > Please don't top post.  Post corrected, see below:
    >
    >
    >
    >
    >
    >
    >
    > > On Mar 21, 10:22 am, "Bob Barrows" <> wrote:
    > >> wrote:
    > >> > I have a page that i need to sort if the user selects the sort
    > >> > radio btn and then hit the link to reload the page.

    >
    > >> This is an ASP newsgroup dealing with question about server-side
    > >> scriptin

    > > g,
    > >> so finding someone to help with a client-side coding question would
    > >> proba

    > > bly
    > >> be easier if you posted it to a client-side scripting newsgroup like
    > >> m.p.scripting.jscript or comp.lang.javascript

    >
    > >> Incidently, I think the term you were looking for is "submit the
    > >> form" rather than "reload the page".

    >
    > > This is asp 3.0 code, that is server side is it not?
    > > what i am doing is changing the sql that will be executed if a radio
    > > button is select.

    >
    > Yes, and no.  You did not ask the right question, and did not really
    > provide any server side code.  You also have some markup problems that
    > should be dealt with as well.
    >
    > <%@ Language=VBScript %>  - this is server side, and really not
    > necessary, although I do recommend placing most of the server side code
    > before anything is output to the client.
    >
    > <html xmlns="http://www.w3.org/1999/xhtml">
    >
    > Why are you attempting to use XHTML?  You would be much better off using
    > HTML.  Your doctype is incorrect - see an HTML group for the proper way
    > to do it.
    >
    > <head>
    > <title></title>
    >
    > No title?  How is the user to be able to tell which page he or she is
    > on?  Especially, if the user needs to change tabs and come back?
    >
    > </head>
    > <body>
    > <%
    >     dim sort, strSQL
    >     sort=Request.QueryString("sort")
    >
    > This part really should be up at the top, before the HTML declaration.  
    > Much easier to debug later.
    >
    >     if sort=1 then
    >             strSQL = strSQL & "ORDER BY Date Desc"
    >     else
    >         strSQL = strSQL & "ORDER BY fName"
    >     end if
    >
    > Understand that 1 is a number, and "1" is a character.  
    > Request.querystring, and request.form return a character, not a number,
    > so this is going to fail.
    >
    > Where is your query?  How can we possibly help you with your query if
    > you don't provide it?
    >
    >  %>
    >
    > I don't see a form element in the markup below.  You need that in order
    > for the information to go anywhere.  I would say that the form should be
    > self-submitting.  So you need something like:
    > <form method="get" action="<%=request.servervariables("script_name")%>">
    > You could use the actual page name, but script name is a little more
    > portable.
    >
    > <div id="SelFra" style="POSITION: absolute; WIDTH: 100%;">
    >    <table  width ="100%" border="0" cellspacing="0"  align="center" >
    >     <tr bgcolor="#aeaeae" >
    >             <td   style="width:200px;">  
    >             <input type="radio" name="rbSort" value="0"
    >                 <% IF sort=1 then Response.Write "Checked" end if %>  /
    >
    > >  Sort by Account Size  

    >
    > You are using XHTML, so it would have to be checked="checked", not
    > Checked (attributes in XHTML are lower case, and cannot be empty),
    > another reason it might fail in modern browsers.
    >
    >                 </td>
    >             <td>
    >                     <a href="Default22.asp?sort=1" >Image</a>
    >                 </td>
    >
    > So the radio button is for presentation only? You would be better off
    > doing something with CSS than this.  
    >
    >         </tr>
    >   </table>
    > </div>
    > </body>
    > </html>
    >
    > You would be better off not using tables for presentation.  Tables are
    > for tabular data, and are a nightmare to maintain, especailly when they
    > are nested.
    >
    > The most important part here is what the server is receiving from the
    > client.  In this case you want to test for:
    >
    > if request.querystring("sort") = "1" then
    >         'do something
    > else
    >         'do something else
    > end if
    >
    > --
    > Adrienne Boswell at Home
    > Arbpen Web Site Design Serviceshttp://www.cavalcade-of-coding.info
    > Please respond to the group so others can share
    , Mar 21, 2010
    #6
  7. Guest

    Ok read the whole thing, 1st thanks so much for the time to give such
    a detailed comment.

    I didnt know xhtml was the case and i cant really change every thing
    being the person that created the page is still with the company and
    it would be bad protocol.

    i think what i really needed to do was check what radio button was
    checked and then set the sql

    I think if i redo the page with a check box not a radio button and
    then at the begining check if the check box was checked that would be
    the answer.

    Sorry for the day 1 questions but how do u check if a check box is
    cheched?
    , Mar 21, 2010
    #7
  8. Gazing into my crystal ball I observed writing in
    news::

    > Ok read the whole thing, 1st thanks so much for the time to give such
    > a detailed comment.
    >
    > I didnt know xhtml was the case and i cant really change every thing
    > being the person that created the page is still with the company and
    > it would be bad protocol.
    >
    > i think what i really needed to do was check what radio button was
    > checked and then set the sql
    >
    > I think if i redo the page with a check box not a radio button and
    > then at the begining check if the check box was checked that would be
    > the answer.
    >
    > Sorry for the day 1 questions but how do u check if a check box is
    > cheched?
    >


    You do it the same way you check for anything coming in from the client.
    It's all about name/value pairs. Name being the name of the form
    control, and value being its value. As I said in my prior post, you
    need to know that a character is going to be returned, not a number.
    So you have to do something like:

    <%
    option explicit

    dim checked

    checked = request.querystring("checkbox")
    if checked = "1" then 'notice the " on either side of the 1
    checked = true
    else
    checked = false
    end if

    %>
    <form method="get" action="<%=request.servervariables("SCRIPT_NAME")%>">
    <p>
    <label for="checkbox">Check me <input name="checkbox" type="checkbox"
    value="1" <% if checked then%>checked="checked"<%end if%> />
    <input type="submit" value="Submit" />
    </p>
    </form>

    This might help you:
    http://www.cavalcade-of-coding.info/requiredform.php

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Mar 22, 2010
    #8
  9. Evertjan. Guest

    Adrienne Boswell wrote on 22 mrt 2010 in
    microsoft.public.inetserver.asp.general:

    > if checked = "1" then 'notice the " on either side of the 1
    > checked = true
    > else
    > checked = false
    > end if
    >


    Agreeing with all you wrote, Adrienne, I still think even a beginner
    should know that testing for true/false this way is a bit of code
    overkill, so I would do:

    checked = checked = "1"

    Morover,
    because I'm to lazy to remember what the browser will return,
    [my Chrome returns "on", I just found], I check for the absence of this
    supposed trueness:

    checked = checked <> ""

    ========= test.asp ==========
    Returned text: <% = request.querystring("myCheckbox") %>
    <hr>
    Testing for "1": <% = request.querystring("myCheckbox")="1" %>
    <hr>
    Testing for "on": <% = request.querystring("myCheckbox")="on" %>
    <hr>
    Testing for not "": <% = request.querystring("myCheckbox")<>"" %>
    <hr>
    <form>
    <input type='checkbox' name='myCheckbox' checked>
    <input type='submit'>
    </form>
    =============================

    This returns if checked and submitted:

    Returned text: on
    Testing for "1": False
    Testing for "on": True
    Testing for not "": True



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Mar 22, 2010
    #9
  10. MikeR Guest

    wrote:
    > Ok I have not read all the msg yet but this is my 1st post ever and
    > also i inherited this code. so what is top posting?


    Top posting is putting your replies on top of the stuff you're replying to, instead
    of after it.

    Mike
    MikeR, Mar 22, 2010
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob Green via .NET 247

    qry returns nothing (no data matched qry)

    Bob Green via .NET 247, Apr 16, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    371
    Sebastian
    Apr 16, 2004
  2. Qry strlen ?

    , Oct 9, 2006, in forum: C Programming
    Replies:
    9
    Views:
    429
    Peter Nilsson
    Oct 10, 2006
  3. Sheth Raxit

    Qry : Behaviour of fgets -- ?

    Sheth Raxit, Sep 6, 2007, in forum: C Programming
    Replies:
    345
    Views:
    5,093
    Flash Gordon
    Oct 20, 2007
  4. Hiten
    Replies:
    1
    Views:
    600
    Vidar Petursson
    May 26, 2004
  5. tnhoe
    Replies:
    1
    Views:
    123
    David Dorward
    Jul 17, 2005
Loading...

Share This Page