Radio Button Nightmare... help !!

Results 1 to 2 of 2

Thread: Radio Button Nightmare... help !!

  1. #1
    Join Date
    Dec 1969

    Default Radio Button Nightmare... help !!

    Hi there, i just don&#039;t have any hair left on my head... i pulled it all out because of this little nightmare. <BR><BR>Were do i begin, i&#039;m trying to Validate a list of 28 radio buttons that form part of a questionaire. Unfortunately, i can only use Server Side Validation for this. The way the questionaire works is that a user is dipalyed a form with the first set of questions. Once they submit this i write there selection into a Session Variable (i ...know i should have used an array ) I also make use of a hidden field that tracks the page they are on. With a case select statement i then call a sub procedure which loads the next set of questions... etc. <BR><BR>heres the code :<BR><BR>&#060;%<BR>sub usersess<BR>dim FormKey<BR>for Each Formkey in request.Form &#039;this is the Radiobutton colect.<BR>Session(FormKey) = request.form(FormKey)&#039; now a session variable<BR>Next<BR>End Sub <BR><BR>Dim Page <BR>if request.form("hid") = "" then &#039; this checks the page num<BR>Page = 1 &#039; if none then we load page one <BR>Else <BR>Page = request.form("hid")&#039; else we go to this page<BR>end if <BR><BR>call usersess<BR>dim rbnum<BR>dim rbval<BR>dim count<BR> <BR>Select Case Page<BR>Case 1 :Call a1 &#039;a1 is a subporocedure with a set of questions.<BR>Case 2 :<BR>For rbnum = 1 To 10<BR>rbval = Session("radiobutton" & rbnum) &#039; get one value <BR>if rbval = "" then &#039; here i check if it has a value <BR>response.write rbval<BR>else <BR>response.write "All ok" <BR>next<BR>end select<BR>end if <BR>%&#062;<BR><BR>I want to be able to validate say the first ten radio buttons on that page ... then if the user has missed one, redirect them back to the form to enter the missed ones....<BR><BR>I hope you guy&#039;s can help me with this one..... any advise appreciated !<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default This one is easy...

    What you see via Request.Form(...) for a Radio Button when no button is pushed on the prior page is the same thing you see when the user doesn&#039;t check a checkbox: ABSOLUTELY NOTHING.<BR><BR>SO:<BR><BR>&#060;%<BR>For i = firstRBnumber To lastRBnumber<BR>&nbsp; &nbsp; If Request.Form("radiobutton" & i) = "" Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write "You didn&#039;t answer question number " & i<BR>&nbsp; &nbsp; End If<BR>Next<BR>%&#062;<BR><BR>Note that doing FOR EACH item IN REQUEST.FORM will *NOT* detect this, as you will simply not get any "item" for the unchecked group of buttons. <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