[ic] Radio button selected

Chris Wenham cwenham at synesmedia.com
Wed Sep 24 14:44:05 EDT 2003


On Wednesday 24 September 2003 12:56, Anthony Minero wrote:
> Can someone tell me how to create a radio button option that is
> automatically selected?

 Best way is to use the [checked] tag so the form remembers the state between 
refreshes.

 First set the default:

[if !value confirm]
	[value name="confirm" set="yes"]
[/if]

 Then in the form:

 <input type="radio" name="confirm" value="yes" [checked name="confirm" 
value="yes"]/> Yes
 <input type="radio" name="confirm" value="no" [checked name="confirm" 
value="no"]/> No

 The [checked] tag will output "CHECKED" in the final HTML if the value of 
"confirm" equals the test value. 

 To do the same with select boxes, you'd use the [selected] tag in a similar 
way:

<select name="confirm">
	<option [selected name="confirm" value="yes"]>yes</option>
	<option [selected name="confirm" value="no"]>no</option>
	<option [selected name="confirm" value="no preference"]>no 
preference</option>
</select>

Regards,
-- 
Chris Wenham
Synesmedia - www.synesmedia.com
Quality Interchange programming & consulting
Phone: 516-620-4110 - Fax: 516-908-7824



More information about the interchange-users mailing list