Radio Button Value

Results 1 to 4 of 4

Thread: Radio Button Value

  1. #1
    Troy Guest

    Default Radio Button Value

    How do I get the radio button value using ASP/VBScript? I have an ASP page where the user can click on a radiobutton (in a set of 3 radiobuttons) and I want to find out which one is clicked when the user hits submit.

  2. #2
    Join Date
    Dec 1969

    Default you give

    them all the same name, and different values... through asp, the radio button that was checked is Request.Form ("nameOfRadio") or Request.QueryString("nameOfRadio") .. through scripting languages it&#039;s <BR>document.formName.nameOfRadio.value<BR><BR>Jas on<BR><BR>good night

  3. #3
    Join Date
    Dec 1969

    Default RE: Radio Button Value

    elements of your asp page<BR>&#060;input type="radio" name="answer" value="a"&#062;<BR><BR>&#060;input type="radio" name="answer" value="b"&#062;<BR><BR>&#060;input type="radio" name="answer" value="c"&#062;<BR><BR>new asp page (form action url):<BR><BR>dim answer<BR>answer = request.form("answer")<BR>

  4. #4
    Join Date
    Dec 1969

    Default CORRECTION!

    The answer re getting the value in ASP is correct, but *ONLY* MSIE 5 and above will give you the value if you use document.FormName.ButtonGroupName.value.<BR><BR>If you want to write code that works in all browsers, you need to write:<BR><BR>function getRadioValue( group )<BR>{<BR>&nbsp; &nbsp; for ( var i = 0; i &#060; group.length; ++i )<BR>&nbsp; &nbsp; {<BR>&nbsp; &nbsp; &nbsp; &nbsp; if ( group[i].checked ) return group[i].value;<BR>&nbsp; &nbsp; }<BR>&nbsp; &nbsp; return "";<BR>}<BR><BR>Similar code is needed in non-MSIE browsers for checkbox and &#060;SELECT&#062; fields, incidentally! <BR><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