Link to home
Start Free TrialLog in
Avatar of qiang8
qiang8

asked on

How to check HTML parameter in VBscript ?

My code:

...
<TR><TD>
<input type='radio' name='ans' value='yes' >
<input type='radio' name='ans' value='no' >
</TD></TR>

How to write the following codes to check whether which of the above is checked and then proceed accordingly.

<%
if (ans=yes) ;How check here??
  Do this
else
  Do that
%>
Avatar of inges
inges

The user can select only one of the options, you get only one value returned.  The browser sends the value of the selected control, so if the user of this form has selected yes you would just get this single entry when using the form collection.  (This works because you have provided a different value for each of the controls.
So use the value attribute.)

Use the form collection.

I thing it's something like this :

Request.form("ans") = "yes"

Avatar of qiang8

ASKER

I have tried the following but wrong ans
given.

<input type='radio' name='ans' value='yes' checked > 
<input type='radio' name='ans' value='no' > 

<%
if( Request.form("ans") = "yes" )then
  Response.Write "Yes"
else if ( Request.form("ans") = "no" )then    
  Response.Write "No"
 else
  Response.Write "No answer"
 end if
end if
%>

The ans is always "No answer". Why?
why you not put different name of radio button
Avatar of qiang8

ASKER

I can't put different names to the radio buttons as I want ONLY one of them to be selected. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of jamestthomas
jamestthomas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please let me know if you got this to work because if not, you are doing something wrong that I, perhaps, can help you with.
Avatar of qiang8

ASKER

Thank yo very much for ur help. It works!