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
%>
qiang8Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ingesCommented:
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"

0
qiang8Author Commented:
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?
0
FRehmanCommented:
why you not put different name of radio button
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

qiang8Author Commented:
I can't put different names to the radio buttons as I want ONLY one of them to be selected. Thanks.
0
jamestthomasCommented:
Actually giang8, if you put that radio contorl in a form with a submit button and the post it to an asp page with your exact server side vbscript the answer will change depending on the selection.  Try it. Put this in a page, say test.htm

<FORM ACTION = "test.asp" METHOD = "post" id=form1 name=form1>


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



<P><INPUT TYPE = SUBMIT id=SUBMIT1 name=SUBMIT1>
</form>

Then create a test.asp to handle the submit.  In test.asp all you need is this:

<%@ Language=VBScript %>
<%
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
%>

It will work if done like this.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jamestthomasCommented:
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.
0
qiang8Author Commented:
Thank yo very much for ur help. It works!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.