Querystring

Results 1 to 5 of 5

Thread: Querystring

  1. #1
    Join Date
    Dec 1969
    Posts
    17

    Default Querystring

    &nbsp;<BR>I have a form which contains a number of radio buttons, which for many reasons I have named differently (radio1, radio2, radio3, etc). When the form is submitted, the radio button which is selected appears in the url of the response page under the name of the button, the other radio buttons are ignored.<BR><BR>What I wish to do is extract the value of the selected radio button. The problem is that the name of the radio button reflected in the url varies dependent on the selected button. <BR><BR>Is there a way to either:<BR>(a)add vbscript to the onclick event of the submit button changing the selected radio button&#039;s name to a consistent value( such as "radio" so that I may use request.querystring(radio) to extract the value. or<BR>(b)write a request.querystring("radio*"), where the * is a wildcard?<BR><BR>Thanks!!<BR>Michael

  2. #2
    Join Date
    Dec 1969
    Posts
    96,118

    Default (b) is easy...

    &#060;%<BR>For Each name In Request.QueryString<BR> If Left(name,5) = "radio" Then<BR> val = Request.QueryString(name)<BR> ... process this value ...<BR> End If<BR>Next<BR>%&#062;<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    96,118

    Default And if you wanted them in an array...

    &#060;%<BR><BR>Dim values( 100 ) &#039; big enough to handle all possible radio buttons<BR>buttonNum = -1<BR><BR>For Each name In Request.QueryString <BR> If Left(name,5) = "radio" Then <BR> buttonNum = buttonNum + 1<BR> values(buttonNum) = Request.QueryString(name) <BR> End If <BR>Next <BR><BR>ReDim Preserve values( buttonNum ) &#039; chop array to exact size<BR><BR>&#039; and if you wanted the values as a delimited string:<BR>valuesAsString = Join( values, "," ) &#039; or whatever<BR><BR>%&#062; <BR>

  4. #4
    Join Date
    Dec 1969
    Posts
    17

    Default Thank You!!

    &nbsp;<BR>Bill - thank you very much... This is a fun project and I&#039;m learning quite a bit along the way!!<BR><BR>BTW - in a prior post, you questioned my use of vbscript. The project is a corporate intranet where the desktops are always standardized on the latest version of MSIE.<BR><BR>Thanks again!!!


  5. #5
    Join Date
    Dec 1969
    Posts
    96,118

    Default BTW: (a) could also be done...

    ...in the browser, by concatenating all the "radioN" values into a single string and putting the result into a TYPE=HIDDEN form field named just "Radio". Then you just ignore the radioN values in the querystring and concentrate on Radio.<BR><BR>[Why a querystring instead of METHOD=POST, incidentally?]<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •