View Full Version : javasctipt and forms with array fields

09-20-2005, 11:33 AM
i can use a command such as ->

window.document.demo.test.value = "updated1";

to update a text field in a form like ->

<input name="test" type="text">

However i want to start using array fields like ->

<input name="test[]" type="text">

But cant work out what i would need in javascript to do the same, any ideas?

09-20-2005, 03:27 PM
Warning: brackets in a name can lead to interesting dilemmas later. ;)
I'm not sure if they are valid html. Might be. Might not be. You might want to check before you start using that. If it isn't valid, some browsers might puke.

That said:

09-20-2005, 05:23 PM
cheers for that mike, works a treat..

i did read on php.net they are used to pass an array though from a form, to php, appose to say having a list of names and passing all that data across thought the url. So long as that holds up i am fine, as the data gets saves in a database.

Thanks for your help...

09-20-2005, 05:42 PM
seem to have found a problem, when using a for next loop.

this works fine.


however this wont

var i = 1;

any ideas????

09-20-2005, 05:54 PM
It's a string. It is not evaluated as a number. Unless...



09-20-2005, 06:14 PM

cheers... at last...... you've been very helpfull, cheers