Link to home
Start Free TrialLog in
Avatar of Lee R Liddick Jr
Lee R Liddick JrFlag for United States of America

asked on

How do I gray out a select box unless a checkbox is clicked?

I have a select box that I want to be grayed out or not active unless a checkbox within the form is checked.  And if it is checked, make sure they make a selection before submitting.  My code is below.  This form is within a cfform in flash format (<cfform format="flash", etc.>).
<cfinput name="chkapprvl"
	type="Checkbox"
	label="This is not approved, check this box to approve/reject the request and make a selection below"
	checked="no"
	align="left">
<CFSELECT name="selStatus"  
	label="Status:"
	query="getQuery"
	value="value"
	display="Name"
                      queryPosition="below"
	width="200">
                <option value="">Select One</option>
</CFSELECT>

Open in new window

Avatar of erikTsomik
erikTsomik
Flag of United States of America image

try this
<cfinput name="chkapprvl"
        type="Checkbox"
        label="This is not approved, check this box to approve/reject the request and make a selection below"
        checked="no"
        align="left" onclick="(selStatus.selectedIndex.selected)">
Avatar of Lee R Liddick Jr

ASKER

I tried this last night and it didn't work...form didn't even load.  Not sure if it's because it's a flash form.
The format is flash...does that make a difference as to why it is not working?  Can anyone else assist?
I received a memo that this question is still open and that's because I haven't received any input.  I'm not sure how I can get this to be visible for responses.  I thought this was something fairly simple to someone who has done this before.
ASKER CERTIFIED SOLUTION
Avatar of Lee R Liddick Jr
Lee R Liddick Jr
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gdemaria
agx's solution for that problem is good, but doesn't cover what happens if you UNCHECK the box.  Wouldn't you want it to disable the SELECT ?

Also, when you load the form originally, is there a chance the checkbox could be checked or not checked?  If so, you need logic to initially disable the select..
<cfinput name="chkapprvl"
	type="Checkbox"
	label="This is not approved, check this box to approve/reject the request and make a selection below"
	checked="no"
onClick="if (this.checked) {document.getElementById('selStatus').disabled=false;} else {document.getElementById('selStatus').disabled=true;}"
 	align="left">
<CFSELECT name="selStatus"  
	label="Status:"
	query="getQuery"
	value="value"
	display="Name"
                      queryPosition="below"
	width="200">
                <option value="">Select One</option>
</CFSELECT>

Open in new window

Btw, Erik's solution (the first post) didn't work because it's not even a command, it's just the variable that represents the selected item of the SELECT tag - the response really doesn't make sense