Phụ thuộc vào việc bạn có cho phép javascript hay không.
Nếu bạn cho phép javascript, hãy sử dụng jQuery để hiển thị/ẩn các div.
Tôi vừa thực hiện tập lệnh thuật sĩ sau. Nó hỗ trợ nhiều trình thuật sĩ trên cùng một trang, miễn là bạn làm theo cú pháp lớp/div bên dưới.
<div class="wizard">
<div class="step active">
some information
</div>
<div class="step" style="display:none">
Step 2 info
</div>
<div class="step" style="display:none">
Step 3 info
</div>
<input type="button" class="prev" style="display: none" value="Previous" />
<input type="button" class="next" value="Next" />
</div>
<script type="text/javascript">
$(function() {
$('.wizard .prev').click(function() {
var wizard = $(this).parent('.wizard');
$('.step.active', wizard).hide();
var currentStep = $('.step.active', wizard);
currentStep.hide();
currentStep.removeClass('active');
var newStep = currentStep.prev('.step', wizard);
newStep.addClass('active');
newStep.show();
if ($('.step:first', wizard)[0] == newStep[0]) {
$(this).hide();
}
$('.next', wizard).show();
});
$('.wizard .next').click(function() {
var wizard = $(this).parent('.wizard');
$('.step.active', wizard).hide();
var currentStep = $('.step.active', wizard);
currentStep.hide();
currentStep.removeClass('active');
var newStep = currentStep.next('.step', wizard);
newStep.addClass('active');
newStep.show();
if ($('.step:last', wizard)[0] == newStep[0]) {
$(this).hide();
}
$('.prev', wizard).show();
});
});
</script>
Nếu không có javascript:
Tạo một mô hình điểm, trong đó có thông tin cho tất cả các bước và chia sẻ nó giữa tất cả các quan điểm bước wizard. Điều này cho phép bạn giữ tất cả trạng thái giữa các POST khác nhau.
Mối liên hệ của Darin với một ví dụ mà anh ta cung cấp trong một câu trả lời là rất có ích trong việc giúp tôi thiết lập trình thuật sĩ trong MVC. – REMESQ
@REMESQ - một cách rất dài để nói 'Cảm ơn, Điều đó đã giúp'. – Dementic