我的第一段未使用 document.all.obj 的JS

来源:互联网 发布:矩阵的奇异值 编辑:程序博客网 时间:2024/05/21 01:42
<form action="" method="post" name="postForm" id="postForm"><tr>
                  <td>
                    <input name="search_value" type="text" class="stdedit_en" id="search_value" size="25"></td></tr>
                     <tr> <td>
                      <select name="sel_search">
                      <option selected value="0">——请选择栏目——</option>
                      <option value="1">图片新闻</option>
                      <option value="2">百君快递</option>
                      <option value="3">百君著述</option>
                      <option value="4">以案说法</option>
                      <option value="5">执业心得</option>
                      <option value="6">法规快递</option>
                      </select>
                       <input name="Submit3" type="button" class="stbuttom_en_02" onClick="src_action()" value="搜索">
                       <script>
                        function src_action()
                        {
                         var txt,sel,url;
                         txt = document.getElementsByName("search_value").item(0).value;
                         sel = document.getElementsByName("sel_search").item(0).value;
                         url = "";
                        
                         if(txt == "")
                         {
                          alert("查询条件不能为空!");
                          return false;
                         }
                         if(txt.indexOf("'")>=0)
                         {
                          alert("查询条件不能包含特殊字符/'!");
                          return false;
                         }
                         if(sel == "0")
                         {
                          alert("请选择你要查询的栏目!");
                          return false
                         }
                         switch(sel){
                          case "1":
                           url = "news/index.asp?class_id=14";
                           break;
                          case "2":
                           url = "news/index.asp?class_id=20";
                           break;
                          case "3":
                           url = "write/index.asp?class_id=21";
                           break;
                          case "4":
                           url = "law/index.asp?class_id=22";
                           break;
                          case "5":
                           url = "gains/index.asp?class_id=23";
                           break;
                          case "6":
                           url = "regula/index.asp?class_id=24";
                           break;
                         }
                         if(url !="")
                         {
                          document.getElementsByName("postForm").item(0).action = url;
                          document.getElementsByName("postForm").item(0).submit()
                         }
                         return false;
                        }
                       </script>
                     </td>
                </tr>
</form>
原创粉丝点击