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

Web Servers

Avatar of undefined
Last Comment
gdemaria

8/22/2022 - Mon
erikTsomik

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)">
ASKER
Lee R Liddick Jr

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.
ASKER
Lee R Liddick Jr

The format is flash...does that make a difference as to why it is not working?  Can anyone else assist?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
Lee R Liddick Jr

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
Lee R Liddick Jr

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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

gdemaria

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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.