- <html>
- <head>
- <script type="text/javascript">
- <!--
- function my_change()
- {
- if(document.getElementById("select_id").value==0)
- {
- document.getElementById("text1").disabled=true;
- document.getElementById("text2").disabled=false;
- document.getElementById("text3").disabled=true;
- document.getElementById("text1").style.backgroundColor="#e9e9e9";
- document.getElementById("text2").style.backgroundColor="#FFF";
- document.getElementById("text3").style.backgroundColor="#e9e9e9";
- }
- else if(document.getElementById("select_id").value==1)
- {
- document.getElementById("text1").disabled=false;
- document.getElementById("text2").disabled=true;
- document.getElementById("text3").disabled=true;
- document.getElementById("text1").style.backgroundColor="#FFF";
- document.getElementById("text2").style.backgroundColor="#e9e9e9";
- document.getElementById("text3").style.backgroundColor="#e9e9e9";
- }
- else
- {
- document.getElementById("text1").disabled=true;
- document.getElementById("text2").disabled=true;
- document.getElementById("text3").disabled=false;
- document.getElementById("text1").style.backgroundColor="#e9e9e9";
- document.getElementById("text2").style.backgroundColor="#e9e9e9";
- document.getElementById("text3").style.backgroundColor="#FFF";
- }
- }
- //-->
- </script>
- </head>
- <body onLoad="my_change();">
- <table>
- <tr>
- <td>
- <select id="select_id" name="select_id" onChange="my_change();">
- <option value="0">0</option>
- <option value="1">1</option>
- <option value="2">2</option>
- </select>
- </td>
- </tr>
- <tr>
- <td><input type="text" id="text1" name="text1"/></td>
- </tr>
- <tr>
- <td><input type="text" id="text2" name="text2"/></td>
- </tr>
- <tr>
- <td><input type="text" id="text3" name="text3"/></td>
- </tr>
- </table>
- </body>
- </html>
本文转自许琴 51CTO博客,原文链接:http://blog.51cto.com/xuqin/942954,如需转载请自行联系原作者