ap***@apple.com wrote:
so how do I get around the error?
document.forms['f'].elements['apple[]'].value = 2;
(must use "apple[]" for server cgi)
Not really. I assume that you are using php, which also supports an
always_populate _raw_post_data directive.
With this directive enbled, you can simply use normal names and still use
arrays:
<form method="post" action="...">
<input type="checkbox" name="fruit" value="apple" /> Apple<br />
<input type="checkbox" name="fruit" value="banana" /> Banana<br />
<input type="checkbox" name="fruit" value="pear" /> Pear<br />
<input type="submit" />
</form>
.....
<?
if (!isset($HTTP_R AW_POST_DATA) ||
!strstr($HTTP_R AW_POST_DATA, 'fruit=')) {
print "Please select some fruits";
} else {
parse_str(
str_replace(
"fruit=",
"fruit[]=",
$HTTP_RAW_POST_ DATA
),
$fruits
);
print "Selected fruits:<br />";
foreach ($fruits['fruit'] as $fruit) {
print "$fruit<br />";
}
}
?>
JW