那么,这里的想法是一次循环所有的页面,虽然每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>
如下您可以尝试在解决问题,然后张贴代码吗? –