Results 1 to 3 of 3

Thread: Disable textbox when ListIndex = 2

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    The Netherlands
    Posts
    96

    Disable textbox when ListIndex = 2

    I have 2 Select Boxes...
    I put an OnChange event on the First Select box....

    If the first listbox' ListIndex = 2...I'd like the second two be disabled...

    If the ListIndex changes again...I want to enable the second listbox...

    The below code does the disabling....but does not check for listindex..help is appreciated

    Code:
    function disablen(veld){ 
      with (document.myForm.elements[veld]) { 
        disabled = !disabled; 
      } 
    }

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Code:
    <script language="javascript">
    function Lists(){
    alert(form1.select.selectedIndex);
    if(form1.select.selectedIndex==2){
    	form1.select2.disabled = 1;
    	form1.select3.disabled = 1;
    } else {
    	form1.select2.disabled = 0;
    	form1.select3.disabled = 0;
    }
    }
    </script>
    <form name="form1" method="post" action="">
      <select name="select" onChange="Lists();">
        <option selected>test</option>
        <option>disable</option>
        <option>test3</option>
      </select>
      <select name="select2">
        <option selected>test</option>
        <option>test2</option>
        <option>test3</option>
        <option>test4</option>
        <option>test5</option>
      </select>
      <select name="select3">
        <option selected>test</option>
        <option>test2</option>
        <option>test3</option>
        <option>test4</option>
      </select>
    </form>
    Don't forget the index starts at 0


  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    did this work satisfactorily for you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width