Hii, I have 2 options in my form: 1)Enter new Subject 2)Enter new Chapter When 1st is selected,i want that automatically the 2nd dropdown should be disabled. Can anyone pls help me? Thnx a lot in advance
Try this: <html> <head> </head> <body> <select id="subject" onchange="this.value != ''? document.getElementById('chapter').disabled=true : document.getElementById('chapter').disabled=false; "> <option value=""></option> <option value="sub1">Subject1</option> <option value="sub2">Subject2</option> <option value="sub3">Subject3</option> </select> <select id="chapter"> <option value=""></option> <option value="chap1">Chapter1</option> <option value="chap2">Chapter2</option> <option value="chap3">Chapter3</option> </select> </body> </html> PHP:
i don't think this is going to work, and if not i have the repleaced code for the onchange="" this.options[this.selectedIndex].value != ''? document.getElementById('chapter').disabled=true : document.getElementById('chapter').disabled=false;
this.value != '' is the same as this.options[this.selectedIndex].value != '' i think. besides i test this code and it works just fine.