我有两个单独的表格,带有单选按钮。我需要点击一个按钮,然后单击提交两个表单。
<form action="/second_vote" method="post" id="poll-view-voting" accept-charset="UTF-8">
<div class="choices">
<div class="form-item form-type-radios form-item-choice">
<div id="edit-choice" class="form-radios">
<div class="form-item form-type-radio form-item-choice">
<input type="radio" id="edit-choice-1" name="choice" value="1" class="form-radio">
<label class="option" for="edit-choice-1">1 </label>
</div>
</div>
</div>
</div>
<input type="submit" id="edit-vote" name="op" value="Vote" class="form-submit">
</form>
<form action="/second_vote" method="post" id="poll-view-voting--2" accept-charset="UTF-8">
<div class="choices">
<div class="form-item form-type-radios form-item-choice">
<div id="edit-choice--2" class="form-radios">
<div class="form-item form-type-radio form-item-choice">
<input type="radio" id="edit-choice-3" name="choice" value="3" class="form-radio">
<label class="option" for="edit-choice-3">1 </label>
</div>
</div>
</div>
</div>
<input type="submit" id="edit-vote--2" name="op" value="Vote" class="form-submit">
</form>
我尝试这样做,但只发送了第一张表格。
<script language="javascript" type="text/javascript">
function submitDetailsForm() {
$('#poll-view-voting').submit();
}
</script>
答案 0 :(得分:0)
我认为您无法在一个请求中发送两个表单。你应该使用一些AJAX请求按顺序发送它们,或者更好的是,只使用一个表单(你对你的两个表单使用相同的action
..)
答案 1 :(得分:0)
您可以使用AJAX提交第一个表单,否则提交一个表单将阻止另一个表单的提交。
答案 2 :(得分:-2)
<form action="/second_vote" method="post" id="poll-view-voting--2" accept-charset="UTF-8">
<div class="choices">
<div class="form-item form-type-radios form-item-choice">
<div id="edit-choice--2" class="form-radios">
<div class="form-item form-type-radio form-item-choice">
<input type="radio" id="edit-choice-3" name="choice" value="3" class="form-radio">
<label class="option" for="edit-choice-3">1 </label>
</div>
</div>
</div>
</div>
</form>
<input type="button" value="Click Me!" onclick="submitDetailsForm()" />
<script language="javascript" type="text/javascript">
function submitDetailsForm() {
$('#poll-view-voting').submit();
$('#poll-view-voting--2').submit();
}
</script>