提交按钮的name='submit'引起的js失效问题及原因

复制代码 代码如下:


<html xmlns=""><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link type="text/css" href="https://www.jb51.net/css/style.css">
</head>
<body>
<form method="post" action="supplierAction!list.action">
<div>
                商品名称:
                <input type="text">
                &nbsp;&nbsp;&nbsp;&nbsp; 是否付款:
                <select>
                    <option value="">
                        请选择
                    </option>
                    <option value="01">
                        已付款
                    </option>
                    <option value="02">
                        未付款
                    </option>
                </select>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <!--就是因为下面这个按钮的名称叫做submit导致js失效-->
                <input value="组合查询" type="submit">
            </div>
<div>每页显示
<select onchange="gotoSelectedPage1()">
<option value="5">5</option>
<option value="10" selected="selected">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>条 共6条记录&nbsp; 第
<input readonly="readonly" value="1" size="3">
页 / 共1页&nbsp;<a href="javascript:page_first();">第一页</a>
<a href="javascript:page_last();">最后一页</a> &nbsp;跳转页码至:
<select onchange="gotoSelectedPage()">
<option value="1" selected="selected">1</option></select></div>
<script type="text/javascript">
function sel(val){return document.getElementById(val);}
var page=sel('curpage');var form=sel('pquery');var select=sel('selectpage');
function page_first() {page.value = 1;form.submit();}
function page_pre() {var a = page.value;a = parseInt(a) - 1;page.value = a;page_validate();form.submit();}
function page_next() {var a = page.value;a = parseInt(a) + 1;page.value = a;page_validate();form.submit();}
function page_last() {page.value = 1;form.submit();}
function page_validate() {var a = page.value;if (a < 1){a = 1;}    if (a > 1){a = 1;}page.value = a;}
function gotoSelectedPage1() {page.value = 1;form.submit();}
function gotoSelectedPage() {page.value = select.value;form.submit();}
</script>
</div>
</form>
</body></html>


name属性删除之后正常运行~~这是什么原因呢,经过一番研究和咨询,一位大神给出了答案

form中元素通过name获取。如果name=submit,那么form.submit得到的应该是 那个input 。所以form.submit()会报 is not a finction 的错误

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgfjxg.html