-1
我應該試着寫一些更詳細的錯誤。 我需要一種問卷調查問卷,只有您可以選擇的幾個答案中的一個。 該問題被分組爲<fieldset>
元素,這些元素在最後一組問題回答後變爲可見。 由於設計原因,我寫了一個設置爲鍵入「按鈕」的幾個button
元素。 我不能讓頁面重新加載回答問卷。<button type =「button」 - 通過POST傳遞值到PHP
現在我想傳遞它們的值,如果點擊到PHP將它們保存到數據庫。
jQuery(document).ready(function($) {
var current = 1,
current_step, next_step, steps;
var buttonname = '';
var buttonvalue = '';
var btnarray = [];
steps = $(".fieldset").length;
$(".next").click(function() {
buttonname = $(this).attr('name');
buttonvalue = $(this).val();
btnarray.push(buttonname + ":" + buttonvalue);
current_step = $(this).parents("fieldset");
next_step = $("fieldset").eq(current);
buttonvalue = $(this).val();
current_step.hide();
next_step.show();
//setProgressBar(++current);
});
});
.parallelogram {
background: #fff;
width: 100%;
height: auto;
position: relative;
border: solid 5px #0793EB;
margin-left: -10px;
transform: skew(-15deg);
font-size: 24pt;
color: #0793EB;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="reg_form" novalidate action="action.php" method="POST">
<fieldset>
<button type="button" class="parallelogram next" name="topic[]" value="1"><span class="text-uppercase boldtext">Button 1-1</span></button>
<button type="button" class="parallelogram next" name="topic[]" value="2"><span class="text-uppercase boldtext">Button 1-2</span></button>
</fieldset>
<fieldset hidden>
<button type="button" class="parallelogram next" name="secondtopic[]" value="1"><span class="text-uppercase boldtext">Button 2-1</span></button>
<button type="button" class="parallelogram next" name="secondtopic[]" value="2"><span class="text-uppercase boldtext">Button 2-2</span></button>
</fieldset>
</form>
在Firebug中,我可以看到的參數,並在預覽中的數組,但var_dump($_POST);
不給我任何東西。
有沒有人有想法?
在此先感謝。
問候。
事情是,這是一個多步驟的形式,我只想在最後提交。所以我將按鈕定義爲type =「button」以留在我的頁面上。 – Gardinero