ColdFusion Tutorial

Adding Radio buttons to a form.

All of your input objects in a form must have their own unique name that will be the label that the browser will assign to them when passing the data. The exceptions are radio buttons. Since only one piece of information will be passed from a set of radio buttons, they all get the same name. HTML requires that one of the buttons is selected by default, the one indicated by the CHECKED command. It is important to understand that the browser will send the name and the value of the selected button, not the text that is associated with the button.

We are going to add two Radio buttons to the form.
Radio button for "Man" and for "Female".

The syntax for Radio button:
<input name="m_f_value" type="radio" value="Man">
or
<input name="m_f_value" type="radio" value="Man" checked>

form1.cfm

<form action="form2.cfm" method="post" name="form1">

First Name:<input name="first_name" type="text" size="20" maxlength="20">

<br>

Last Name:<input name="last_name" type="text" size="20" maxlength="20">

<br>

Man: <input name="m_f_value" type="radio" value="Man" checked>

Female<input name="m_f_value" type="radio" value="Female">

<br>

<select name="country">

<option value="Afghanistan">Afghanistan</option>

<option value="Albania">Albania</option>

<option value="Bahamas">Bahamas</option>

<option value="Belgium">Belgium</option>

<option value="Canada">Canada</option>

<option value="China" selected>China</option>

</select>

<br>

<input name="upload_person" type="submit" id="upload_person" value="Submit -->">

</form>


 form2.cfm

First Name: <cfoutput>#Form.first_name#</cfoutput>

<br>

Last Name: <cfoutput>#Form.last_name#</cfoutput>

<br>

<!--- test radio buttons --->

<cfswitch expression = "#Form.m_f_value#">

<cfcase value="Man">

You are a man.

</cfcase>

<cfcase value="Female">

You are a female.

</cfcase>

</cfswitch>

<br>

Country: <cfoutput>#Form.country#</cfoutput>

For more information about Radio buttons, see this tutorial.

ColdFusion Tutorial test

Adding Radio buttons to a form.

No test is available or implemented for this ColdFusion Tutorial.

No User Comments.

No User Comments, be the first one to write your comments?

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
7bT
Your IP Address: 38.103.63.62
 

ScandicWeb is own by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.

[Home [Site Map [Privacy Statement [Site Feedback] [About ScandicWeb]


[ColdFusion [Flash [Search Engine Optimization [Graphics [Cascading Style Sheets (CSS) [JavaScript (JS) [Software]

Partner sites: ScandicSoft


Server time: 19. November 2008 Wednesday