那麼,這裏的想法是一次循環所有的頁面,雖然每10個問題包括一個類與一個div,確保添加樣式:除了第一個隱藏的所有。
然後你可以添加下面的按鈕來顯示然後一個接一個地隱藏div。
所以像這樣?
<form class="" action="index.php" method="post">
<?php $i = 0; ?>
<?php foreach ($questions as $q): ?>
<?php if (($i % 10) == 0): //Multipal of 10 ?>
<?php if ($i == 0): ?>
<div class="page">
<?php else: ?>
<div class="page" style="display:none;">
<?php endif; ?>
<?php endif; ?>
<label for="<?=$q?>">Label: <?=$q?></label><input type="text" name="<?=$q?>"><br/>
<?php $i++; ?>
<?php if (($i % 10) == 0): ?>
<?php if (count($questions) != $i): ?>
<button type="button" class="next-page">Next</button>
<?php else: ?>
<input type="submit" name="name" value="Submit">
<?php endif; ?>
</div>
<?php else: ?>
<?php endif; ?>
<?php endforeach; ?>
</form>
<script type="text/javascript">
$('.next-page').on('click', function(){
var currentPage = $('.page');
currentPage.first().hide();
currentPage.first().next().show();
});
</script>
如下您可以嘗試在解決問題,然後張貼代碼嗎? –