Posted by Marek Kilimajer on 04/11/05 02:32
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);
Navigation:
[Reply to this message]
|