Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Dynamic assignment from array

Posted on 2004-09-21
2
Medium Priority
?
609 Views
Last Modified: 2008-02-01
I have a form with text fields: note0, note1, note2, etc.  The number of these items will vary (i.e. sometimes just note0 and sometimes note0 to note100)

I have an array dataArray with the same number of items as the number of notes.

I would like to create a loop like this:

for(i=0; i < dataArray.length; i++){
    note + i.value = dataArray[i];
}

but of course there is a problem with "note + i.value".  Can anyone suggest how I can dynamically assign to a variable like this?
0
Comment
Question by:derekpapesch
2 Comments
 
LVL 6

Accepted Solution

by:
viola123 earned 2000 total points
ID: 12119520
           <script language="javascript">
            function test(){
                  for(i=0; i < dataArray.length; i++){
                        document.getElementById("note" + i).value = dataArray[i];
                  }
            }

            </script>
      </head>
      <body>
            <INPUT id="note1" type="text" name="Text1"><br>
            <INPUT id="note2" type="text" name="Text2"><br>
            <INPUT id="note3" type="text" name="Text3"><br>
            <INPUT id="note4" type="text" name="Text4">
      </body>



regards
viola
0
 
LVL 4

Author Comment

by:derekpapesch
ID: 12119655
Beautiful.

Thanks for your help Viola!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question