Re: JS refering to HTML/PHP arrays

From: Date: Sun, 07 Oct 2001 23:49:26 +0000
Subject: Re: JS refering to HTML/PHP arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70400@lists.php.net to get a copy of this message
On Mon, 08 Oct 2001 19:24:25 -0400, Jason G. wrote: >First of all, Array[] is a reserved keyword, and I would recommend >using >something else. > >Give each element an ID > ><input type="text" name="myarray[name]" id="txtName"> > >In Javascript: > ><script language="javascript"> > alert(txtName.value); ></script> that really defeats the purpose of the array I think because then you have to reference it by the id you gave it instead of the array name. A better solution might be to use: <input type="text" name="myarray[name]"> <script language="javascript"> var f=document.forms[0];// or whatever number form it is alert(f.elements["myarray[name]"]); </script>

« previous php.general (#70400) next »