Ok... This is the PHP page I was testing it with:
HTML Code:
<?php
print_r($_POST);
?>
<script type="text/javascript">
var chkboxTicked = new Image();
chkboxTicked.src = "test/chkbox_ticked.png";
var chkboxEmpty = new Image();
chkboxEmpty.src = "test/chkbox_empty.png";
function submitcheckboxes(){
var checkboxes = document.getElementsByName("imagecheckboxes");
for(var i in checkboxes){
var location = document.getElementById("form1");
var input = document.createElement('input');
input.setAttribute('style','display:none;');
input.setAttribute('type','hidden');
input.setAttribute('name',checkboxes[i].title);
input.setAttribute('id',checkboxes[i].title);
location.appendChild(input);
if(checkboxes[i].src == chkboxTicked.src){
document.getElementById(checkboxes[i].title).value = "1";
} else {
document.getElementById(checkboxes[i].title).value = "0";
}
}
return true;
}
function toggleChkBox(that){
if(that.src == chkboxEmpty.src){
that.src = chkboxTicked.src;
} else {
that.src = chkboxEmpty.src;
}
}
</script>
<form id="form1" method="post" action="tester.php" onsubmit="return submitcheckboxes()">
<img name="imagecheckboxes" src="test/chkbox_empty.png" onclick="toggleChkBox(this)" title="box1" />
<img name="imagecheckboxes" src="test/chkbox_empty.png" onclick="toggleChkBox(this)" title="box2" />
<input type="submit" name="submit" />
</form>
For me, that returned:
Code:
Array ( [submit] => Submit Query [box1] => 0 [box2] => 1 [undefined] => )
See the names of my image tickboxes are box1 and box2? That's how the tickboxes are submitted.
So, if you put in php:
PHP Code:
<?
if($_POST['box1'] == 1){
print "Box 1 was ticked";
}
?>
It will write 'Box 1 was ticked' if box 1 was ticked.
Similarly, you can just write the following for the same result:
PHP Code:
<?
if($_POST['box1']){
print "Box 1 was ticked";
}
?>