+1 for karim79 for specifying jQuery / AJAX and $ _POST thingy. Very important.
Here is a solution without jQuery (if you're not interested in learning jQuery right now)
Step 1: Add onchange even to checkbox tags like this:
<p><label><input name="gender" type="radio" value="male" onchange="do_submit()" <?php if($_POST['gender']=='male'){?>checked="checked"<? }?> /> Male</label></p>
<p><label><input name="gender" type="radio" value="female" onchange="do_submit()" <?php if($_POST['gender']=='female'){?>checked="checked"<? }?> /> Female</label></p>
Step 3: Add a name attribute to create a tag like this:
<form name="myform" action="check.php" method="post">
Step 3: Write an onchange event handler function in javascript:
<script type="text/javascript">
function do_submit() {
document.forms['myform'].submit();
}
</script>
Several important notes.
- $ _ POST is better than $ _REQUEST.
- Use
<?php
php tag instead of short form <?
. It will be deprecated in future php versions.
- The time to invest in jQuery / AJAX training is 100% worth the time and effort.
source
to share