Ok, I am pretty stumped, looking in this code for more than 3 hours.
I generate array of check boxes, like this:
<?php
while($row=mysql_fetch_array($result)){
// here generate some more html...
echo '<table><tr><td><input type="checkbox" name ="ordered" onchange="checked()"/></td></tr>'
echo "</table>";
?>
I have two js functions like this:
<head>
<script>
function removeDuplicateElement(arrayName){
var newArray=new Array();
label:for(var i=0; i<arrayName.length;i++ ){
for(var j=0; j<newArray.length;j++ ){
if(newArray[j]==arrayName[i])
continue label;
}
newArray[newArray.length] = arrayName[i];
}
return newArray;
}
var array = new Array();
function checked(){
var chkOrd = document.myForm.ordered;
for (i=0; i < chkOrd.length; i++){
if(chkOrd.checked){
array.push(chkOrd[i]);
//document.myForm.hid.value =chkOrd[i].value;
document.myForm.hid.value += removeDuplicateElement(array);
//alert("kliknuto je na " + array[1]);
}
}
}
</script>
</head>
and when i post infos to php with this:
$hid = $_POST['hid'];
echo $hid;
I always get empty array, like no checkboxes is passed to php. I know that php sends on only checked checkboxes, but my array is empty even if there are checked boxes... I think that there are some problem with generated checkboxes, because i cannot even get single item of checked boxes array.
Thank you in advance...