Ben başka bir sayfa yenileniyor ama yine aynı sayfada / yeniden / yeniden yönlendirme olmadan kontrol onay kutusu ile formu göndermek istiyorsanız.
and my targets:
checkbox gizleme sonra sessiz ve formu gönderme teslim sonra
<div id="question1"><!--the form here--></div>
ve bölümlerini göstermektedir
<div id="question2" style="<?php echo ($agree) ? 'display:block;' : 'display:none;' ?>"><!--some fields here--></div>
existing cases: I have the form as following that seem won't work,
<div id="question1">
<form action="<?php echo $submit); ?>" method="post" id="question" onsubmit="processForm();return false;">
<!--some rows here -->
<?php if ($quote['id'] == $color || !$color) { ?>
<?php $color = $quote['id']; ?>
<input type="radio" name="prefer_color" value="<?php echo $quote['id']; ?>" id="<?php echo $quote['id']; ?>" checked="checked" style="margin: 0px;" />
<?php } else { ?>
<input type="radio" name="prefer_color" value="<?php echo $quote['id']; ?>" id="<?php echo $quote['id']; ?>" style="margin: 0px;" />
<?php } ?>
<?php foreach ($prefer_places as $prefer_place) { ?>
<tr>
<td width="1">
<?php if ($prefer_place['id'] == $place || !$place) { ?>
<?php $place= $prefer_place['id']; ?>
<input type="radio" name="prefer_place" value="<?php echo $prefer_place['id']; ?>" id="<?php echo $prefer_place['id']; ?>" checked="checked" style="margin: 0px;" />
<?php } else { ?>
<input type="radio" name="prefer_place" value="<?php echo $prefer_place['id']; ?>" id="<?php echo $prefer_place['id']; ?>" style="margin: 0px;" />
<?php } ?></td>
</tr>
<?php } ?>
<?php if ($agree) { ?>
<input type="checkbox" name="agree" value="1" checked="checked" onchange="if(this.checked) this.form.processForm() ? $('#question2').css('display','block') : $('#question2').css('display','none');" id="agree" /><label for="agree">Agree</label>
<?php } else { ?>
<input type="checkbox" name="agree" value="1" onclick="if(this.checked) this.form.processForm() ? $('#question2').css('display','block') : $('#question2').css('display','none');" id="agree" /><label for="agree">Agree</label>
<?php } ?>
</form>
</div>
<div id="question2" style="<?php echo ($agree) ? 'display:block;' : 'display:none;' ?>">
<!--some fields here-->
</div>
Bu kod ile, onay kutusunu sonra formu teslim ancak ve başka bir sayfaya yönlendirme kontrol etti.
Ben takdir biraz yardım ve işaretçiler gerekir.
Çok teşekkür ederiz.
Updated,
Ajax görünüyor gibi bu işleme kullanım Ajax ile yönergeleri izleyerek, bu yüzden ben bunu deneyin:
<script type="text/javascript">
function processForm() {
$.ajax( {
type: 'POST',
url: 'index.php?p=form/questions_steps',
data: 'prefer_color=' + encodeURIComponent(document.getElementById('input[name=\'<?php echo $quote['id']; ?>\']:checked').value) ? document.getElementById('input[name=\'<?php echo $quote['id']; ?>\']:checked').value : '') + '&prefer_color=' + encodeURIComponent(document.getElementById('input[name=\'<?php echo $prefer_color['id']; ?>\']:checked').value) ? document.getElementById('input[name=\'<?php echo $prefer_color['id']; ?>\']:checked').value : '') + '&comment=' + encodeURIComponent(document.getElementById('textarea=[name=\'comment\']').value) + '&agree=' + encodeURIComponent(document.getElementById('input[name=\'agree\']:checked').value) ? document.getElementById('input[name=\'agree\']:checked').value : ''),
success: function(data) {
$('#message').html(data);
}
} );
}
</script>