<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>
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号