This is kind of basic, and I googled but didn't find much help.
I have an array of text element fields. They all need to have the same
name. So, let the name be either all with a[] or build individually as
a[0], a[1], a[2], etc. The brackets need to be there because I will
obtaining the values of them as an array using $_POST{'a'] in php.
What I want to do is in javascript set the value of an individual
element, say a[3]. I have tried many combinations of
1 - setting the ids all as
a) a
b) a[]
c) individually as a[0], a[1], etc.
2 - using document.getEle mentById
3 - using document.getEle mentsByName
Any time I create and object from the name, and then try to use that
object, I get "object has no properties" in Firebug. This is true
whether I try obj.value or obj[i].value.
So, please,
1 - How do I set the id attribute?
2 - How do I access or set an individual member in the array?
3 - For the name attribute, should I use a[] or individually build them
or does it not matter as far as javascript is concerned?
Yes, this is basic, but I have been going in circles for a few hours now
so any help will be appreciated.
I have an array of text element fields. They all need to have the same
name. So, let the name be either all with a[] or build individually as
a[0], a[1], a[2], etc. The brackets need to be there because I will
obtaining the values of them as an array using $_POST{'a'] in php.
What I want to do is in javascript set the value of an individual
element, say a[3]. I have tried many combinations of
1 - setting the ids all as
a) a
b) a[]
c) individually as a[0], a[1], etc.
2 - using document.getEle mentById
3 - using document.getEle mentsByName
Any time I create and object from the name, and then try to use that
object, I get "object has no properties" in Firebug. This is true
whether I try obj.value or obj[i].value.
So, please,
1 - How do I set the id attribute?
2 - How do I access or set an individual member in the array?
3 - For the name attribute, should I use a[] or individually build them
or does it not matter as far as javascript is concerned?
Yes, this is basic, but I have been going in circles for a few hours now
so any help will be appreciated.
Comment