?
Solved

Select Box Disable

Posted on 2000-05-12
2
Medium Priority
?
207 Views
Last Modified: 2008-03-04
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????)
0
Comment
Question by:markdmolder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
julieg earned 100 total points
ID: 2806723
I used a disabling procedure by entering a number in a text box and if say the number was 4, 4 drop down boxes would be disabled, 5, 5 disabled etc.  I used a set disable and setright functions I created myself then onchange command and onsubmit command in Javascript.  The text box looked like this:

Number of Weeks Eligible (must use drop down boxes below to indicate week of vacation):
<td width="368">
<input type="text" Name="NoWeeks" onchange="setdisable()"></td></tr>
</table>

And then all the necessary code was before it:

<script language="javascript">

function setright(){
if (document.vacpost.submit){
document.vacpost.DateA.disabled=false;
document.vacpost.DateB.disabled=false;
    document.vacpost.DateC.disabled=false;
      document.vacpost.DateD.disabled=false;
        document.vacpost.DateE.disabled=false;
          document.vacpost.DateF.disabled=false;
            document.vacpost.DateG.disabled=false;
                  }
                  }

function setdisable(){
if (document.vacpost.NoWeeks.value=="1"){
  document.vacpost.DateB.disabled=true;
    document.vacpost.DateC.disabled=true;
      document.vacpost.DateD.disabled=true;
        document.vacpost.DateE.disabled=true;
          document.vacpost.DateF.disabled=true;
            document.vacpost.DateG.disabled=true;
  }
  if (document.vacpost.NoWeeks.value=="2"){
    document.vacpost.DateA.disabled=false;
      document.vacpost.DateB.disabled=false;
    document.vacpost.DateC.disabled=true;
      document.vacpost.DateD.disabled=true;
        document.vacpost.DateE.disabled=true;
          document.vacpost.DateF.disabled=true;
            document.vacpost.DateG.disabled=true;
  }
    if (document.vacpost.NoWeeks.value=="3"){
        document.vacpost.DateA.disabled=false;
      document.vacpost.DateB.disabled=false;
    document.vacpost.DateC.disabled=false;
      document.vacpost.DateD.disabled=true;
        document.vacpost.DateE.disabled=true;
          document.vacpost.DateF.disabled=true;
            document.vacpost.DateG.disabled=true;
  }
    if (document.vacpost.NoWeeks.value=="4"){
            document.vacpost.DateA.disabled=false;
      document.vacpost.DateB.disabled=false;
    document.vacpost.DateC.disabled=false;
          document.vacpost.DateD.disabled=false;

        document.vacpost.DateE.disabled=true;
          document.vacpost.DateF.disabled=true;
            document.vacpost.DateG.disabled=true;
  }
    if (document.vacpost.NoWeeks.value=="5"){
                document.vacpost.DateA.disabled=false;
      document.vacpost.DateB.disabled=false;
    document.vacpost.DateC.disabled=false;
          document.vacpost.DateD.disabled=false;

        document.vacpost.DateE.disabled=false;

          document.vacpost.DateF.disabled=true;
            document.vacpost.DateG.disabled=true;
  }
    if (document.vacpost.NoWeeks.value=="6"){
                    document.vacpost.DateA.disabled=false;
      document.vacpost.DateB.disabled=false;
    document.vacpost.DateC.disabled=false;
          document.vacpost.DateD.disabled=false;

        document.vacpost.DateE.disabled=false;

          document.vacpost.DateF.disabled=false;

            document.vacpost.DateG.disabled=true;
  }
 
      if (document.vacpost.NoWeeks.value=="7"){
                    document.vacpost.DateA.disabled=false;
      document.vacpost.DateB.disabled=false;
    document.vacpost.DateC.disabled=false;
          document.vacpost.DateD.disabled=false;

        document.vacpost.DateE.disabled=false;

          document.vacpost.DateF.disabled=false;

            document.vacpost.DateG.disabled=false;
  }

  }
 


</script>
0
 
LVL 3

Expert Comment

by:bark10
ID: 2811131
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.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question