1) If POST value is set save the content from the POST value in a variable.
if(isset($_POST["spart"])) {
$spart = $_POST["spart"];
}else{
$spart = '';
}
2) If variable contains a certain value, make the input field checked.
<input id="radio_dump_select_spart1x2" class="copy" type="radio" name="spart" value="1x2" <?php if ($spart=="1x2") echo 'checked="checked"';?>>
The problem now is that some jQuery functions should be called if a checkbox is checked. I already have them in the header but they only work if the user clicks on it. It doesn’t work if it is set in PHP like described above.
3) OK, let’s try to call some actions if input is checked:
<input id="radio_dump" type="radio" name="spart" value="1x2" <?php if ($spart=="1x2") echo 'checked="checked"';?> onclick="if($(this).is(':checked')) { alert('test'); hide_them_all(); $('#select_tb').show(); }; return true"> Text</div>
I thought I could use the onclick attribute, but it seems that it won’t work.
This is how it can be done:
You can insert this almost anywhere with no problems.