occio
11-04-2003, 03:54 AM
Hi all. This is my problem.
I have to sent with a form some values of a unique variable.
To do it, i use an array, of course.
However, I have to control the values, before to send them, cause if the user check a value, the others values have to become '' ''. So I found your script ''Controlled Boxes'', in Forms Area.
I paste the code to explain better.
***** your script to control values *****
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkChoice(field, i) {
if (i == 0) { // "All" checkbox selected.
if (field[0].checked == true) {
for (i = 1; i < field.length; i++)
field[i].checked = false;
}
}
else { // A checkbox other than "Any" selected.
if (field[i].checked == true) {
field[0].checked = false;
}
}
}
// End -->
</script>
***** the form (it's inside a 'while') *****
<form method=POST action="second.php" name=thisForm>
<input type="checkbox" name="prog[]" value="0" onclick="checkChoice('document.thisForm.prog[]', 0)" checked><b>Name1</b>
<? .......... // here I query db
$i = 1;
while($row = mysql_fetch_object($query)) { ?>
<input type="checkbox" name="prog[]" value="<?=$row->prog?>" onclick="checkChoice('document.thisForm.prog[]', <?=$i?> )"><?=$row->name?>
<br>
$i = $i+1;
}
?>
<input type=submit value=submit>
</form>
The control with 'checkChoice' is on first field: in fact, if you check first field, you cannot check following fields; instead, if you check following fields, you can check more of them, but not the first, because if you check the first one, it will uncheck the others.
This control with javascript is correct without php array 'prog[]'.
But if I insert php array 'prog[]', launching the page, it gives error on javascript... I suppose for the existing of two arrays, javascript's one and php's other.
However, I have to send to second page values with the javascript control on first page, cause if user check first field, he have not to check other fields, while if he uncheck first field he can check one or more of other fields.
The problem is here. These values have to been stored in second page into db, so I have manipulate them, before inserting, as an array... if I don't use php array I cannot receive in second page multiple values.
Any ideas?
Thank you a lot. Bye.
I have to sent with a form some values of a unique variable.
To do it, i use an array, of course.
However, I have to control the values, before to send them, cause if the user check a value, the others values have to become '' ''. So I found your script ''Controlled Boxes'', in Forms Area.
I paste the code to explain better.
***** your script to control values *****
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkChoice(field, i) {
if (i == 0) { // "All" checkbox selected.
if (field[0].checked == true) {
for (i = 1; i < field.length; i++)
field[i].checked = false;
}
}
else { // A checkbox other than "Any" selected.
if (field[i].checked == true) {
field[0].checked = false;
}
}
}
// End -->
</script>
***** the form (it's inside a 'while') *****
<form method=POST action="second.php" name=thisForm>
<input type="checkbox" name="prog[]" value="0" onclick="checkChoice('document.thisForm.prog[]', 0)" checked><b>Name1</b>
<? .......... // here I query db
$i = 1;
while($row = mysql_fetch_object($query)) { ?>
<input type="checkbox" name="prog[]" value="<?=$row->prog?>" onclick="checkChoice('document.thisForm.prog[]', <?=$i?> )"><?=$row->name?>
<br>
$i = $i+1;
}
?>
<input type=submit value=submit>
</form>
The control with 'checkChoice' is on first field: in fact, if you check first field, you cannot check following fields; instead, if you check following fields, you can check more of them, but not the first, because if you check the first one, it will uncheck the others.
This control with javascript is correct without php array 'prog[]'.
But if I insert php array 'prog[]', launching the page, it gives error on javascript... I suppose for the existing of two arrays, javascript's one and php's other.
However, I have to send to second page values with the javascript control on first page, cause if user check first field, he have not to check other fields, while if he uncheck first field he can check one or more of other fields.
The problem is here. These values have to been stored in second page into db, so I have manipulate them, before inserting, as an array... if I don't use php array I cannot receive in second page multiple values.
Any ideas?
Thank you a lot. Bye.