提交多个按钮单击以表单操作

时间:2016-08-31 02:13:13

标签: jquery html forms

当我单击“下一步”按钮时,我想将按钮标签中按下的按钮提交给表单操作。

HTML

<div id="Submit-answer" display: inline-block;"><button type="submit">Next</button>
    </div>

输入标签通过帖子提交,但按钮标签不发送任何表单信息。有没有办法让这些数据提交?像解决方法或者我错过了一些东西。我需要知道用户是否为每个div单击是或否。我正在使用jquery来切换活动的类,所以是的,不能同时选择

HTML

    <form method="post" action="http://truthsandlie.com/check.php">
    <div id="Answertoggle16">
    <div id="questions-box">
<input type="hidden" name="question16" value="Question1">
<input type="hidden" name="key"  value="5"><input type="hidden" name="user"  value="truthsandlie">
<button type="button" name="yes5" id="answerf1" class="lietruth yes" >Yes</button>
<button type="button" name="no5" id="answer1" class="lietruth no" >No</button>
    <div id="questions">Question1</div>
    </div>
    </div>
    <div id="Answertoggle17">
    <div id="questions-box">
<input type="hidden" name="question17" value="Question2"><input type="hidden" name="key"  value="9">
<input type="hidden" name="user"  value="truthsandlie">
<button type="button" name="yes9" id="answerf1" class="lietruth yes" >Yes</button>
<button type="button" name="no9" id="answer1" class="lietruth no" >No</button>
    <div id="questions">Question2</div>
    </div>
    </div>
    <div id="Answertoggle18">
    <div id="questions-box">
<input type="hidden" name="question18" value="Question3">
<input type="hidden" name="key"  value="25">
<input type="hidden" name="user"  value="truthsandlie"><button type="button" name="yes25" id="answerf1" class="lietruth yes" >Yes</button>
<button type="button" name="no25" id="answer1" class="lietruth no" >No</button>
    <div id="questions">Question3</div>
    </div>
    </div>
    <div id="Answertoggle19">
    <div id="questions-box">
<input type="hidden" name="question19" value="Question4"><input type="hidden" name="key"  value="30">
<input type="hidden" name="user"  value="truthsandlie">
<button type="button" name="yes30" id="answerf1" class="lietruth yes" >Yes</button>
<button type="button" name="no30" id="answer1" class="lietruth no" >No</button>
    <div id="questions">Question4</div>
    </div>
    </div>
    <div id="Submit-answer" display: inline-block;"><button type="submit">Next</button>
    </div>

JQuery的

jQuery("#Answertoggle10 .lietruth").click(function(){
        jQuery("#Answertoggle10 .lietruth").removeClass('active');
        jQuery(this).toggleClass('active'); 
});
jQuery("#Answertoggle11 .lietruth").click(function(){
        jQuery("#Answertoggle11 .lietruth").removeClass('active');
        jQuery(this).toggleClass('active'); 
});
jQuery("#Answertoggle12 .lietruth").click(function(){
        jQuery("#Answertoggle12 .lietruth").removeClass('active');
        jQuery(this).toggleClass('active'); 
});

1 个答案:

答案 0 :(得分:0)

<form method="post" id="click-next" action="http://truthsandlie.com/check.php">

$( "form#click-next > button" ).trigger( "click" );

这样可以将点击的按钮提交到https://truthsandlie.com/ check.php页面吗?

以下更新是我所做的。谢谢你的帮助!

Send multiple button information through form