naveendk.55 Posted August 25, 2011 Share Posted August 25, 2011 Hi below form works in Firefox but not in Internet Explorer. Once I select YES the first text box should be disabled and the value should be 10. Once I select NO, then the second box should be enabled and third box value should be 0. This works normally in Firefox but not in Internet Explorer 7. <html> <head> <title>Untitled</title> <script> function enable() { document.myForm.textbox.disabled = false; document.myForm.textbox2.value = 0; } function disable() { document.myForm.textbox.disabled = true; document.myForm.textbox2.value = 10; } function value() { document.myForm.textbox2.value = 10; } </script> </head> <body> <form name="myForm"> <table> <tr> <label> Do you accept </label> <td> <select name="na"> <option value="yes" onclick="disable()"> YES </option> <option value="no" onclick="enable()"> NO </option> <option value="NA" onclick="disable()"> NA </option> </select> <input type="text" name="textbox" value="" disabled> <input type="text" name="textbox2" value="10" > </td> </tr> <tr> <td> </td> </tr> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/245672-scripting-issue-help/ Share on other sites More sharing options...
Abuda Posted August 25, 2011 Share Posted August 25, 2011 The following modification works fine. I substituted the "onClick" function with a "onChange", and removed the JS value() function since there was no use for it. <html> <head> <title>Untitled</title> <script language="JavaScript"> function process(val) { if(val == "no") { document.myForm.textbox.disabled = false; document.myForm.textbox2.value = 0; }else{ document.myForm.textbox.disabled = true; document.myForm.textbox2.value = 10; } } </script> </head> <body> <form name="myForm"> <table> <tr> <label> Do you accept </label> <td> <select name="na" onChange="process(this.value);"> <option value="yes"> YES </option> <option value="no"> NO </option> <option value="NA"> NA </option> </select> <input type="text" name="textbox" value="" disabled> <input type="text" name="textbox2" value="10" > </td> </tr> <tr> <td> </td> </tr> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/245672-scripting-issue-help/#findComment-1261990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.