Collecting checked radio button value of a HTML form in ASP

Radio buttons in a form in ASP is used to collect user's choice. Here radio button is used when user has to select one of the many options presented. For example we want the visitor should say the mode of transport he select while traveling. Here one of the four options is to be decided by the visitor so we can use radio button here. As a part of the form component radio buttons can be used along with other components of a form. We will discuss here only the handling of radio button in a form and collecting the radio button value through ASP.

A group of radio buttons will have same name but different values. In a form there can be any number of groups of radio buttons but each group of buttons will have same name.

We will try here with one group of radio button giving the visitor to select one choice but same can be extended to more than one group of radio buttons. Here is the code to display a group of radio buttons inside an html form.

<form method=post action=form-radiock.asp>
<input type=radio name=t1 value='road'>Road
<input type=radio name=t1 value='rail'>Rail
<input type=radio name=t1 value='air'>Air
<input type=radio name=t1 value='ship'>Ship
<input type=submit value='Submit'>
</form>

As we submit the form the value of the selected radio button will be available at the action page and we can collect the value of this radio button like this.

Dim mode
mode=Request("t1")
Response.Write " Mode of Transport is " & mode

This way the selected mode of transport will be available for further processing.


Be the first to post comment on this article :

plus2net.com




Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer