您的位置:首页 > 其它

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

2016-07-16 21:04 489 查看
<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>这样才能能够生效

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息