form表单内input框name和onclick方法不能重名(同一From表单多个按钮可以submit时发现)

来源:互联网 发布:php linux 删除文件 编辑:程序博客网 时间:2024/06/05 00:01
<pre name="code" class="html"><form  name="oper_tjg" method="post"><input type="button" name="tran_1" onclick="tran()" value="转发"><input type="button" name="judg_1"onclick="judg()" value='评论'><input type="button" name="good_1"onclick="good()" value='点赞'></form><script type="text/javascript">function tran() {document.oper_tjg.action="tran.php";    document.oper_tjg.submit();}function judg() {document.oper_tjg.action="tran.php";    document.oper_tjg.submit();}function good() {document.oper_tjg.action="tran.php";    document.oper_tjg.submit();}</script>
这样点击无效果

<form name="oper_tjg" method="post"><input type="button" name="tran" onclick="tran()" value="转发"><input type="button" name="judg"onclick="judg()" value='评论'><input type="button" name="good"onclick="good()" value='点赞'></form><script type="text/javascript">function tran() {document.oper_tjg.action="tran.php"; document.oper_tjg.submit();}function judg() {document.oper_tjg.action="";document.oper_tjg.submit();}function good() {document.oper_tjg.action=" ";document.oper_tjg.submit();}</script>这样才能能够生效

0 0