faqts : Computers : Programming : Languages : PHP : kms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 4 people (75%) answered Yes
Recently 3 of 4 people (75%) answered Yes

Entry

How to get working an html tag array (name="test[]") in javascript and php

Sep 30th, 2002 15:49
Alex Dean, atu, Jenni Koskenpää, Ashish Chamoli, Alex Dean


Here are some responses to when I posted the same problem...  You can
refer to the select element by number instead of name in JS, but this
quickly becomes a problem because it breaks every time you add a form
input above the select.
I want to name a SELECT 'someSelect[]' for PHP, but I think the '[]' 
are illegal in JS.  Help.
http://www.faqts.com/knowledge_base/view.phtml/aid/16885
-------------------------------------------------------------
------------------
Just add
ID="ListBoxName"
to your existing listbox, after alteration which will look like :
Name="ListBoxName[]" ID="ListBoxName"
and thereafter it will solve the problem of different names for 
JavaScript and PHP.
Take Care,
Ashish Chamoli
------------------
Above doesn't work with Netscape so I prefer naming your script like 
below: 
<select name="var[]" multiple>
And Javascript like: 
variable = documents.forms[0].elements['var[]'];
See more help: http://www.php.net/manual/en/faq.html.php
-Jenni