markdmolder
asked on
Select Box Disable
Is there a way to disable one select box using another to do so? heres the scenerio: we have a credit card list like visa,mastercard, etc.. in the list we also have COD... if this is selected i want to disable the month and year select boxes we have.... i got the script so it doesn't error but it doesn't work!!!!! here it is...
function CheckPay()
{
var checker,checke
var choice = document.PostIt.cboPayType .toString( );
checker = "Cash";
checke = "Call";
if ((choice.indexOf(checker) < 0) || (choice.indexOf(checke) < 0)) {
document.PostIt.cboMonth.d isabled = true;
document.PostIt.cboYear.di sabled = true;
}
else {
document.PostIt.cboMonth.d isabled = false;
document.PostIt.cboYear.di sabled = false;
}
}
i run this function onBlur of the credit select box (and yes the names of the select boxes begin with cbo????)
function CheckPay()
{
var checker,checke
var choice = document.PostIt.cboPayType
checker = "Cash";
checke = "Call";
if ((choice.indexOf(checker) < 0) || (choice.indexOf(checke) < 0)) {
document.PostIt.cboMonth.d
document.PostIt.cboYear.di
}
else {
document.PostIt.cboMonth.d
document.PostIt.cboYear.di
}
}
i run this function onBlur of the credit select box (and yes the names of the select boxes begin with cbo????)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<script language="JavaScript">
function CheckPay()
{
if (PostIt.cboPayType.selecte
{
PostIt.cboMonth.disabled = true;
PostIt.cboYear.disabled = true;
}
else
{
PostIt.cboMonth.disabled = false;
PostIt.cboYear.disabled = false;
}
}
</script>
Just change the selectedIndex value (##) in the script to the value of the index for your COD option.
Also, a better call would be with the onChange() event when compared to the onBlur(), as this does not require the user to click else where for the script to run. As soon as he selects an option, it runs.