Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uncheck checkboxes dynamically

Status
Not open for further replies.

RAxel

MIS
Sep 8, 2005
121
US
Hey all,

I have a setup like this:
Radio Button1 name = Q01 value = Q01A
Checkbox1 name = Q01A01A
Checkbox2 name = Q01A01B
Radio Button2 name = Q01 value = Q01B
Checkbox1 name = Q01B01A
etc...

I have Radio Buttons that belong to the same group, and most of the radio buttons have checkboxes that belong to them (as illustrated above). This is more of an error-validation problem than anything.

This is the problem- a user selects Radio Button1 then selects both checkboxes associated with it. However, let's say the user goes back over his answers and says, no, I don't want Radio Button1, and he selects Radio Button2 instead and the checkbox undearneath that. The problem is that the two checkboxes undear Radio Button1 are still selected. How can I make ColdFusion turn off those checkboxes when their Radio Button is off?

Thanks.
 
you need javascript to do it as it happens, or re-thing the form layout. for cf to do it, the form would have to be submited, and sent back.

 
Do you know of any good sites that show examples of Javascript and coldfusion working together? I've looked but haven't really found a place yet.
 
they don't work together, coldfusion runs on the server, javascript runs after the file is already in the browser.

you can dynamically write the javascript just you can dynamically write out the html with coldfusion. So you can have coldfusion write out the javescript vairables to match coldfusion variables or whatever.

you would need javascript to check or uncheck buttons while another one is clicked. you should probably re-think the form layout if you are running into this sort of issue.

 
I'm not sure how to rethink it. The page loads with the users answers so the user can change them.

It seems javascript is the only way to add this kind of usability.

When a user clicks a radio button, ColdFusion (using the onClick event) expands what's undearneath the radio button and collapses the other radio button.

By the way, in the onClick event, there is a piece of code which I can't find anywhere- either on the internet, in Coldfusion help, or in the code itself somewhere else. It is this: onClick = "shownested_RB(this, 'whatever the table row id is');" Where does this shownested_RB come from?
 
RAxel said:
When a user clicks a radio button, ColdFusion (using the onClick event) expands what's undearneath the radio button and collapses the other radio button.

That is Javascript changing it, not Coldfusion. Coldfusion runs on the server, Javascript runs on the browser, this is why Coldfusion cannot alter the page once it has been sent to the browser, it needs to be resubmitted in some way for it to be able to run.

RAxel said:
By the way, in the onClick event, there is a piece of code which I can't find anywhere- either on the internet, in Coldfusion help, or in the code itself somewhere else. It is this: onClick = "shownested_RB(this, 'whatever the table row id is');" Where does this shownested_RB come from?

Where did you get the code from?

Hope this helps

Wullie

Fresh Look - Quality Coldfusion 7/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
@Wullie: I was told to go in to an already made website and modify some things so that shownested_RB... was already in the code, and in the onClick event so I thought that was some kind of feature in ColdFusion because I couldn't find that as a javascript function anywhere.

At any rate, I believe I'll have to look at the onChange event and send that to some javascript function to uncheck checkboxes and hide the checkboxes under their respective radio button.

Any suggestions? Thanks.
 
if you can't find the function in the page you stole the code from it's probably in a linked .js file.

either way CF only creates the text the browser sees. this text can be javascript or html or whatever.

for example
Code:
<cfset name = "TruthInSatire"> <!--- this is CF --->
<script language = "javascript"> <!--- this is html --->
alert('Hello my name is <cfoutput>#name#</cfoutput>') <!--- this is a combination of cf and js--->
</script><!--- this is html again --->
by the time the browser gets your page all the CF is gone. all you will see is is
Code:
<script language = "javascript">
alert('Hello my name is TruthInSatire')
</script>
if you want to change the content on the page once the page is loaded ("name" for example) you need to do that with js forum216

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top