0

Hi folks i am a beginer to Java script so appologies if this is a dumb question. I am trying to put the following in a for loop but I can't seem to get it to work.

if (rowID==1) { document.form1.class_titleDis_1.value=class_title; } if (rowID==2) { document.form1.class_titleDis_2.value=class_title;

}

This is what I tried

var i=1;
for (i=1;i<=2;i++)
{
  document.form1.(class_titleDis_)+i.value=class_title;
}

I would be really grateful for any suggestions. Graham

1 Answer 1

0
document.form1.(class_titleDis_)+i.value=class_title;

Should likely be:

document.form1['class_titleDis_'+i].value=class_title;
Sign up to request clarification or add additional context in comments.

1 Comment

You are an absoulte star, worked perfectly! You would not believe how many permutations of this I had tried. So many many thanks. Graham

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.