Skip to main content
Inspiring
March 13, 2008
Question

Radio button populating checkbox

  • March 13, 2008
  • 5 replies
  • 857 views
Ok this might be an odd request but what I am tring to do is I have a form that has two radio buttone a yes and a no. If the user selects yes then I want an check box to be checked and if the user selects a no then I want it to be unselected. I can not for the lif of me figure out how to do this.

Radio button code:
<cfinput type="radio" name="YesNo" label="Yes" value="1" onClick="Update(1)" checked/>
<cfinput type="radio" name="YesNo" label="No" value="0" onClick="Update(0)" />

the checkbox I am trying to control
<cfinput type="checkbox" name="FQID_16" label="<= Check if true" value="1" tooltip="#qryFQID_16.popuphelp#" width="115" onchange="removeSelection()" visible="true"/>

I can only think I need to write some javascript to handle this event but unsure how to do this since I am new to CF.

Any help would be appreciated.
This topic has been closed for replies.

5 replies

Inspiring
March 18, 2008
no, you can't. not with CFinput. with regular input fields you can.
with cfinput either use iif() function or surround your whole <cfinput
..> tag with cfif block.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Inspiring
March 18, 2008
Try using EQ instead of the = sign

<cfif YesNoFormat(qryFQID_16_Response.respVal) EQ yes>checked</cfif>

--
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com


"Luckbox72" <webforumsuser@macromedia.com> wrote in message
news:frogmd$gh4$1@forums.macromedia.com...
>I also have another issue. When I try to imbed a cfif inside the input I
>get
> the error A cfinput tag beginning on line 80, column 26. I have read many
> articles saying this is possible.
>
>
> <cfinput type="radio" name="YesNo" id="YesNo" label="Yes" value="1"
> onclick="blah('true')" <cfif
> YesNoFormat(qryFQID_16_Response.respVal)#=yes>checked</cfif>/>
> <cfinput type="radio" name="YesNo" id="YesNo" label="No" value="0"
> onclick="blah('false')" <cfif #YesNoFormat(qryFQID_16_Response.respVal)# =
> yes><cfelse>checked</cfif>/>
>
>

Luckbox72Author
Inspiring
March 18, 2008
I also have another issue. When I try to imbed a cfif inside the input I get the error A cfinput tag beginning on line 80, column 26. I have read many articles saying this is possible.


<cfinput type="radio" name="YesNo" id="YesNo" label="Yes" value="1" onclick="blah('true')" <cfif YesNoFormat(qryFQID_16_Response.respVal)#=yes>checked</cfif>/>
<cfinput type="radio" name="YesNo" id="YesNo" label="No" value="0" onclick="blah('false')" <cfif #YesNoFormat(qryFQID_16_Response.respVal)# = yes><cfelse>checked</cfif>/>
Luckbox72Author
Inspiring
March 14, 2008
Thanks for the help. I knew it was something simple, but my lack of knowledge was making this harder than it was.
Luckbox72Author
Inspiring
March 18, 2008
Ok I tried this code and when the screen loads it does not populate the screen with anything. All I get is an empty screen.
Luckbox72Author
Inspiring
March 18, 2008
I have now tried this code
<cfinput type="radio" name="YesNo" id="YesNo" label="Yes" value="1" onclick="blah('true')" />
<cfinput type="radio" name="YesNo" id="YesNo" label="No" value="0" onclick="blah('false')" />

then
function blah(selectedValue){
alert(selectedValue);
FQID_16.selected = selectedValue;
}

I get the proper alert but reguardless of yes on no being clicked the check box always get checked. What is wrong with this code
Inspiring
March 14, 2008
<cfinput type="radio" name="YesNo" id="YesNo" label="Yes" value="1"
onclick="this.form.FQID_16.checked=true" />
<cfinput type="radio" name="YesNo" id="YesNo" label="No" value="0"
onclick="this.form.FQID_16.checked=false" />

--
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com


"Luckbox72" <webforumsuser@macromedia.com> wrote in message
news:frc8qs$1ih$1@forums.macromedia.com...
> Ok this might be an odd request but what I am tring to do is I have a form
> that
> has two radio buttone a yes and a no. If the user selects yes then I want
> an
> check box to be checked and if the user selects a no then I want it to be
> unselected. I can not for the lif of me figure out how to do this.
>
> Radio button code:
> <cfinput type="radio" name="YesNo" label="Yes" value="1"
> onClick="Update(1)"
> checked/>
> <cfinput type="radio" name="YesNo" label="No" value="0"
> onClick="Update(0)" />
>
> the checkbox I am trying to control
> <cfinput type="checkbox" name="FQID_16" label="<= Check if true"
> value="1"
> tooltip="#qryFQID_16.popuphelp#" width="115" onchange="removeSelection()"
> visible="true"/>
>
> I can only think I need to write some javascript to handle this event but
> unsure how to do this since I am new to CF.
>
> Any help would be appreciated.
>