Accessing form field values
Posted: Fri Jun 29, 2007 3:56 pm
Can someone tell me the best way to access form field values when they have assigned array indexes?
For example:
So then I want to test if the value is checked..
I don't get any errors, but it doesn't work either.
For example:
Code: Select all
<form name="bar" method="post" action="#">
<input type="checkbox" name="foo[11]" onClick="is_checked(11);" value="checked" />
<input type="checkbox" name="foo[12]" onClick="is_checked(12);" value="checked" />
<input type="checkbox" name="foo[13]" onClick="is_checked(13);" value="checked" />
<input type="checkbox" name="foo[14]" onClick="is_checked(14);" value="checked" />
</form>
Code: Select all
function is_checked(int_index)
{
if (document.bar.foo[ind_index].checked != true)
{
alert('foo[' + int_index + '] is checked.');
} else {
alert('foo[' + int_index + '] is NOT checked.');
}
}