Viewing By Entry / Main
Sep 23, 2005
Selecting a Radio Button in a Flash Form
A colleague of mine was trying to figure out how you could select a radio button based upon a value returned by Flash Remoting in a CF Flash form. The answer turned out to be fairly simple it seems. You can select a radio button in a group based upon its value. Here is a vary simple form to show illustrate this:
<cfsavecontent variable="action">
_root.r1.selectedData = 5;
</cfsavecontent>
<cfform format="flash" name="form1">
<cfinput type="radio" name="r1" label="Radio 1" value="1">
<cfinput type="radio" name="r1" label="Radio 2" value="2">
<cfinput type="radio" name="r1" label="Radio 3" value="5">
<cfinput type="button" name="button1" value="Click Me" onclick="#action#">
</cfform>
_root.r1.selectedData = 5;
</cfsavecontent>
<cfform format="flash" name="form1">
<cfinput type="radio" name="r1" label="Radio 1" value="1">
<cfinput type="radio" name="r1" label="Radio 2" value="2">
<cfinput type="radio" name="r1" label="Radio 3" value="5">
<cfinput type="button" name="button1" value="Click Me" onclick="#action#">
</cfform>
All this does is select the radio element with the value of 5 when you click the button. You can change the value and see that it will change which element it selects. So, to use this with Flash Remoting it should be as simple as saying selectedData equal to the value returned by your remoting call (my colleague is testing that out...if it isn't that easy, I will add an update).
Comments
I posted an entry about the remoting half of this over on my blog.
http://simb.net/index.cfm?do=blog.entry&entry=831E18FB-F4C8-4EEA-29B150E4AF477962
http://simb.net/index.cfm?do=blog.entry&entry=831E18FB-F4C8-4EEA-29B150E4AF477962

