JavaScript & PHP arrays ...
Posted: Sat Nov 02, 2002 6:27 am
Hi there,
i have a form
With this form in php i have an array $_POST['form'] with elements name and surname. This is O.K.
I can't validate this form via JavaScript
becouse an error "name is not defined"
When change JavaScript whit this:
everything works fine.
sub_form[name] is the name of input element, but JavaScript looks for array 'sub_form' with 'name' element.
Any idea how to solve this ? I need to tell JavaScript that 'sub_form[name]' is the name io element, not variable.
i have a form
Code: Select all
<form action="blabla.php" action="POST">
<input name="sub_formїname]" />
<input name="sub_formїsurname]" />
..............
</form>I can't validate this form via JavaScript
Code: Select all
....
if (inForm.sub_formїname].value =="") {alert("Please fill name"); return false;};
....When change JavaScript whit this:
Code: Select all
...
if (inForm.elementsї1].value =="" ) {alert("Please fill name"); return false;};
...everything works fine.
sub_form[name] is the name of input element, but JavaScript looks for array 'sub_form' with 'name' element.
Any idea how to solve this ? I need to tell JavaScript that 'sub_form[name]' is the name io element, not variable.