Re: php and javascript

From: Date: Sun, 10 Apr 2005 23:32:39 +0000
Subject: Re: php and javascript
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-212767@lists.php.net to get a copy of this message
PartyPosters wrote:
Hello, I have a form that when I hit sumbit I want to test the varialble in javascript. I can get it working using test variables in php but I want to be able to call the input box in my form, the only problem is the name of the box is in an array (i think) as it's in a list. You can see the 2 samples of the code below which will hopefully make more sence. Can anyone help me out? Thanks. <head> <SCRIPT language=JavaScript> function checkdata() { alert(document.Selection.quantity[0].value) alert("TEST") return true } </SCRIPT> </head> --------------------------------------------------------------- while ($row=mysql_fetch_array($mysql_result)) { echo "<TR> <INPUT NAME = \"distID[]\" TYPE = \"HIDDEN\" VALUE=\"$distID\"> </TR>"; }
Assuming your form is named "Selection", you will have a javascript array document.forms['Selection'].elements['distID[]'] available. You can try: alert(document.forms['Selection'].elements['distID[]'][0].value);

« previous php.general (#212767) next »