Rumah > Artikel > hujung hadapan web > html问题_html/css_WEB-ITnose
<td> <select name="paym" id="imo"> <option value="money" selected>aaa</option> <option value="check" >yyy</option> <option value="card">xxx</option> </select> </td> </tr> <tr> <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;"> <font color="#FFFFFF"><b>bbb</b></font></th> <td> <script type="text/javascript"> var a=document.getElementById("imo").value; if (a=="check") document.getElementById("baoxiao").disabled=true; </script> <input type="text" id="baoxiao" maxlength="10" /> </td>
楼主是要禁用文本框吗? 给你看一篇博文:利用JQuery自定义扩展来禁用表单元素: http://www.ido321.com/397.html
<td> <select name="paym" id="imo"> <option value="money" selected>aaa</option> <option value="check" >yyy</option> <option value="card">xxx</option> </select> </td> </tr> <tr> <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;"> <font color="#FFFFFF"><b>bbb</b></font></th> <td> <script type="text/javascript"> var a=document.getElementById("imo").value; if (a=="check") document.getElementById("baoxiao").disabled=true; </script> <input type="text" id="baoxiao" maxlength="10" /> </td>
<td> <select name="paym" id="imo" onchange="test()"> <option value="money" selected>aaa</option> <option value="check" >yyy</option> <option value="card">xxx</option> </select> </td> </tr> <tr> <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;"> <font color="#FFFFFF"><b>bbb</b></font></th> <td> <script type="text/javascript"> function test(){ var a=document.getElementById("imo").value; if (a=="check") document.getElementById("baoxiao").disabled=true; } </script> <input type="text" id="baoxiao" maxlength="10" /> </td>
js 是以事件跟用户进行互动的,demo要发完整的代码,这样才有助于你问题的快速解决。
看不懂的地方,百度查一下。都是很基础的一些点。
<!DOCTYPE html><html><head> <meta charset="utf-8"/> <title>test</title> <style type="text/css"> input{ line-height:30px;} .disabled{ border:1px solid #ccc; background: #f1f1f1;} </style></head><body><table> <tr> <td> <select name="paym" id="imo"> <option value="money" selected>aaa</option> <option value="check" >yyy</option> <option value="card">xxx</option> </select> </td> </tr> <tr> <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;"> <font color="#FFFFFF"><b>bbb</b></font></th> <td> <input type="text" id="baoxiao" maxlength="10" /> </td> </tr></table><script type="text/javascript"> var a=document.getElementById("imo"); var txt=document.getElementById("baoxiao"); a.onchange = function(e){ e = e || event; var target = e.target || e.srcElement; if(target.value == 'check'){ txt.className = 'disabled'; txt.disabled = true; } else { txt.className = ''; txt.disabled = false; } }</script></body></html>
js 是以事件跟用户进行互动的,demo要发完整的代码,这样才有助于你问题的快速解决。
看不懂的地方,百度查一下。都是很基础的一些点。
<!DOCTYPE html><html><head> <meta charset="utf-8"/> <title>test</title> <style type="text/css"> input{ line-height:30px;} .disabled{ border:1px solid #ccc; background: #f1f1f1;} </style></head><body><table> <tr> <td> <select name="paym" id="imo"> <option value="money" selected>aaa</option> <option value="check" >yyy</option> <option value="card">xxx</option> </select> </td> </tr> <tr> <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;"> <font color="#FFFFFF"><b>bbb</b></font></th> <td> <input type="text" id="baoxiao" maxlength="10" /> </td> </tr></table><script type="text/javascript"> var a=document.getElementById("imo"); var txt=document.getElementById("baoxiao"); a.onchange = function(e){ e = e || event; var target = e.target || e.srcElement; if(target.value == 'check'){ txt.className = 'disabled'; txt.disabled = true; } else { txt.className = ''; txt.disabled = false; } }</script></body></html>
<td> <select name="paym" id="imo" onchange="test()"> <option value="money" selected>aaa</option> <option value="check" >yyy</option> <option value="card">xxx</option> </select> </td> </tr> <tr> <th height="10%" width="10%" align="center" bgcolor="#1a60a8" style="border:1px solid #000000;"> <font color="#FFFFFF"><b>bbb</b></font></th> <td> <script type="text/javascript"> function test(){ var a=document.getElementById("imo").value; if (a=="check") document.getElementById("baoxiao").disabled=true; } </script> <input type="text" id="baoxiao" maxlength="10" /> </td>