日期:2014-05-17 浏览次数:20676 次
<script>
function goBack(id,o){
document.getElementById(id).style.display='block';
o.parentNode.style.display='none';
}
function goNext(id,o){
document.getElementById(id).style.display='block';
o.parentNode.style.display='none';
}
</script>
<form action="demo.php" method="post">
<div id="id1">
<input type="text" name="id1" value=''>
<input type="text" name="id2" value=''>
<input type="button" name="ida" value='按钮1' onclick="goNext('id2',this)">
</div>
<div id="id2" style="display:none">
<input type="text" name="id3" value=''>
<input type="text" name="id4" value=''>
<input type="button" name="idb" value='返回2' onclick="goBack('id1',this)">
<input type="button" name="idc" value='按钮2' onclick="goNext('id3',this)">
</div>
<div id="id3" style="display:none">
<input type="text" name="id4" value=''>
<input type="text" name="id5" value=''>
<input type="button" name="ide" value='返回3' onclick="goBack('id2',this)">
<input type="submit" name="idf" value='提交'>
</div>
</form>
------解决方案--------------------
保存在session里, 外加个状态, 根据请求和当前状态做状态转移和数据的session记录.
------解决方案--------------------
看了半天,总算搞明白你的意思了
看看这个测试例,应该是你想要的
<form method=post>
<?php
$num = 2;
$p = 0;
$h = 0;
$mh = 0;
$val = array_fill(0, $num, '');
if($_POST) {
$h = $_POST['h'];
$mh = max($_POST['mh'], count($_POST['id']));
if(isset($_POST['s'])) {
$h++;
if($h * $num >= $mh) $val = array_merge($_POST['id'], $val);
else $val = $_POST['id'];
}else {
$val = $_POST['id'];
$h--;
}
}
foreach($val as $k=>$v) {
if(floor($k/$num) == $h) {
$t = $k+1;
echo "文本$t<input type=text name=id[$k] value='$v'>";
}else
echo "<input type=hidden name=id[$k] value='$v'>";
}
echo "<input type=hidden name=mh value=$mh>";
echo "<input type=hidden name=h value=$h>";
echo "<input type=submit name=s value='提交'>";
i