ColdFusion Tutorial

ColdFusion radio buttons

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.

Example code for radio buttons:

<!--- radio_buttons.cfm --->

What is your favorite pet?<br>

<form action="test_radio_button.cfm" method="post" name="pet">

Pig: <input name="fovorite_pet" type="radio" value="Pig" checked> <br>

Bird: <input name="fovorite_pet" type="radio" value="Bird"> <br>

Fish: <input name="fovorite_pet" type="radio" value="Fish"> <br>

Cat: <input name="fovorite_pet" type="radio" value="Cat"> <br>

Dog: <input name="fovorite_pet" type="radio" value="Dog"> <br>

Rabbit: <input name="fovorite_pet" type="radio" value="Rabbit"> <br>

<input name="submit_button" type="submit">

</form>

 

<!--- test_radio_button.cfm --->

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

<cfcase value="Pig">

Your favorite pet is pig....

</cfcase>

<cfcase value="Bird">

Your favorite pet is bird....

</cfcase>

<cfcase value="Fish">

Your favorite pet is fish....

</cfcase>

<cfcase value="Cat">

Your favorite pet is cat....

</cfcase>

<cfcase value="Dog">

Your favorite pet is dog....

</cfcase>

<cfcase value="Rabbit">

Your favorite pet is rabbit....

</cfcase>

</cfswitch>

ColdFusion Tutorial test

ColdFusion radio buttons

No test is available or implemented for this ColdFusion Tutorial.

User Comments: 1

 CF Radio Buttons

Thank you very much for this tutorial. I was trying to send the value of the radio buttons via the JS array and transform it to CF and was having a hell of a time. This is plain and simple and works very well.

Thanks again

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
Ld4
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