我的代码中出现了这个重大故障,我忘了按钮不能在PHP中的isset()只提交按钮。
我在表单中使用了next和prev按钮,因此他们可以在旁边显示已选中的单选按钮。
但是我需要在转到下一个单选按钮之前验证表单,当我尝试将按钮转换为提交按钮时它会出现故障并且不会转到下一个单选按钮。
帮我转换这些按钮代码以提交和整理我的javascript,一整天都在努力,我想我又忘记了一些事情......
HTML
<form action="reservation_next_sample.php" method="POST">
<input type="radio" name="next[]" value="1" checked="checked">
<input type="radio" name="next[]" value="2" />
<div id="next1" class="desc">
<div class="div-details">
<h4>Event's Detail</h4>
<table>
<tr>
<td>
Street
</td>
<td>
<input type="text" name="event_street">
</td>
</tr>
<tr>
<td>
Barangay
</td>
<td>
<input type="text" name="event_brgy">
</td>
</tr>
<tr>
<td>
Town/City
</td>
<td>
<input type="text" name="event_town_city">
</td>
</tr>
<tr>
<td>
Province
</td>
<td>
<input type="text" name="event_province">
</td>
</tr>
</table>
<br>
<button type="button" onclick="dayNavigation('next');" data-role="none" class="slick-prev" aria-label="Next" tabindex="0" role="button">Next</button>
</div>
<div id="next2" class="desc" style="display: none;">
<p> inside of next 2 </p>
<button type="button" onclick="dayNavigation('prev');" data-role="none" class="slick-next" aria-label="Previous" tabindex="0" role="button">Previous</button>
<button type="button" onclick="dayNavigation('next');" data-role="none" class="slick-prev" aria-label="Next" tabindex="0" role="button">Next</button>
</div>
</form>
JAVASCRIPT
<script>
$(document).ready(function() {
$("input[name$='next[]']").click(function() {
var test = $(this).val();
$("div.desc").hide();
$("#next" + test).show();
});
});
//this is in the bla bla next and previous -->
var index = 0;
dayNavigation = function(direction) {
var curr = $('input[name="next[]"]:checked');
if (direction == 'next') {
curr.next().attr("checked", "checked");
curr.next().click();
} else {
curr.prev().attr("checked", "checked");
curr.prev().click();
}
};
</script>
答案 0 :(得分:0)
您可以使用jQuery提交表单示例如下。不要更改提交按钮
$("button[type=button]").click(function(){
this.closest("form").submit();
})
而不是选择 $(&#34;按钮[type = button]&#34;)之类的按钮,而不是选择按钮ID并选择特定按钮 $(&#34;#ButtonIdWillGoesHere& #34)强>