根据下拉列表中选择的选项隐藏行

当我在dd(站点上是否有可用的路由器)中选择"no"时,我会得到"是否需要处理新的路由器"下拉列表.现在我想要的是,我在(2)dd中选择"is the Router Make Available from Existing List"这个下拉列表,但它不能工作plz Help.

选择 | 换行 | 行号
  1. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  2. <head>
  3. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  4. <title>Show/Hide</title>
  5. <script type="text/javascript">
  6. // <![CDATA[
  7. function display(obj,id1,id2) {
  8. txt = obj.options[obj.selectedIndex].value;
  9. document.getElementById(id1).style.display = 'none';
  10. document.getElementById(id2).style.display = 'none';
  11. if ( txt.match(id1) ) {
  12. document.getElementById(id1).style.display = 'block';
  13. }
  14. if ( txt.match(id2) ) {
  15. document.getElementById(id2).style.display = 'block';
  16. }
  17. }
  18. // ]]>
  19. </script>
  20. <script type="text/javascript">
  21. function display1(obj,id1,id2) {
  22. txt = obj.options[obj.selectedIndex].value;
  23. document.getElementById(id1).style.display = 'none';
  24. document.getElementById(id2).style.display = 'none';
  25. if ( txt.match(id1) ) {
  26. document.getElementById(id1).style.display = 'block';
  27. }
  28. if ( txt.match(id2) ) {
  29. document.getElementById(id2).style.display = 'block';
  30. }
  31. }
  32. // ]]>
  33. </script>
  34. </head>
  35.  
  36. <body>
  37. <table width="340" cellspacing="0" cellpadding="2">
  38. <thead>
  39. <tr>
  40. <td class="title">Is there a router available at the site :</td>
  41. <td class="field">
  42. <select name="type" onchange="display(this,'yes','no');">
  43. <option>Please select:</option>
  44. <option value="yes">Yes</option>
  45. <option value="no">No</option>
  46. </select>
  47. </td>
  48. </tr>
  49. </thead>
  50.  
  51. <tbody id="yes" style="display: none;">
  52. <tr>
  53. <td class="title">Make:</td>
  54. <td class="field"><input type="text" name="make"  /></td>
  55. <td class="title">Model:</td>
  56. <td class="field"><input type="text" name="model" /></td>
  57. </tr>
  58. <tr>
  59. <td class="title">Sr no:</td>
  60. <td class="field"><input type="srno" name="make"  /></td>
  61. <td class="title">Accesories/Card:</td>
  62. <td class="field"><input type="text" name="card" /></td>
  63. </tr>
  64. </tbody>
  65.  
  66. <tbody id="no" style="display: none;">
  67.  
  68. <tr>
  69. <td class="title"> Does a new Router is required to be processed:</td>
  70. <td class="field"><select name="info" onchange="display1(this,'yes1','no1');">
  71. <option value="-1">Select</option>
  72. <option value="Yes">Yes</option>
  73. <option value="No">No</option>
  74. </select></td>
  75. </tr>
  76.  
  77. <tbody id="no1" style="display: none;">
  78. <tr>
  79. <td class="title">Is the Router made available from existing stock:</td>
  80. <td class="field"><select name="stock"  >
  81. <option value="-1">Select</option>
  82. <option value="Yes">Yes</option>
  83. <option value="No">No</option>
  84. </select></td>
  85. </tr>
  86.  
  87. </tbody>
  88. </tbody>
  89.  
  90.  
  91.  
  92. </table>
  93. </body>
  94. </html>

标签: Javascript

添加新评论