document.form and array?

F

Flyzone

Hi, i have a little trouble with javascript putting data in a form
html.
I'm parsing an xml file with DomXML (into an hta file), in a loop:

if (i==0) {
document.form.moduleA_0.value = varnameA;
document.form.moduleB_0.value = varnameB;
...
else if (i==1) {
document.form.moduleA_1.value = varnameA;
document.form.moduleB_1.value = varnameB;
...
else if (i==2) {
document.form.moduleA_2.value = varnameA;
document.form.moduleB_2.value = varnameB;
...
And in the html form, many input field idetify by the name moduleA,
moduleB.....
That is very boring.
There is a way to identify them in javascript as 'moduleA_'+i like an
array,
or to write as array? I tried to make a moduleA = new array(10), but i
get many
errors in thml.
Could someone give me some tips? Reading in the old posts didn't help
me (wrong key search?).
Thanks in advance
 
R

RobG

Hi, i have a little trouble with javascript putting data in a form
html.
I'm parsing an xml file with DomXML (into an hta file), in a loop:

if (i==0) {
document.form.moduleA_0.value = varnameA;
document.form.moduleB_0.value = varnameB;
...
else if (i==1) {
document.form.moduleA_1.value = varnameA;
document.form.moduleB_1.value = varnameB;
...
else if (i==2) {
document.form.moduleA_2.value = varnameA;
document.form.moduleB_2.value = varnameB;
...
And in the html form, many input field idetify by the name moduleA,
moduleB.....
That is very boring.
There is a way to identify them in javascript as 'moduleA_'+i like an
array,

Yes (though what you are dealing with is not an array even though you
can access it by index):

var form = document.form;
form['moduleA_' + i] = varnameA;
form['moduleB_' + i] = varnameB;


see :

<URL: http://www.jibbering.com/faq/#FAQ4_39 >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top