Link to home
Start Free TrialLog in
Avatar of markdmolder
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.disabled = true;
            document.PostIt.cboYear.disabled = true;
      }
      else {
            document.PostIt.cboMonth.disabled = false;
            document.PostIt.cboYear.disabled = false;
      }
}



i run this function onBlur of the credit select box (and yes the names of the select boxes begin with cbo????)
ASKER CERTIFIED SOLUTION
Avatar of julieg
julieg

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 bark10
bark10

Why not use something as simple as this:

<script language="JavaScript">
function CheckPay()
{
      if (PostIt.cboPayType.selectedIndex==2)
            {
            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.