I am trying to create an array, that will prompt the user for the amount of items they have for sale, then to name the items they have for sale. I then want the correct amount of boxes to appear on screen, with labels beside each box that match the users input. I then have to do some further things, but im doing the code in sections, and before I go on to make it do the next thing, I want to make sure this part works! so far i have figured out how to write all the code for the prompts to come up and so on, and before I attempted to include the correct name beside each box, as entered by the user, it was showing me the right number of boxes on screen, for the number that was entered. but now it just comes up with the submit button :S could anyone please help, what have i done wrong?
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <title>Activity 2.33</title>
- </head>
- <script type="text/javascript">
- var Items;
- var ItemNames=new Array();
- ItemNames[0]="value 1";
- ItemNames[1]="value 2";
- Items=prompt("How many items would you like to sell?")
- LoopCounter= 1;
- element=document.getElementsByTagName('input');
- document.write ("<form name='myform'><br><table>");
- for (NameCount=0; NameCount<Items; NameCount ++)
- {
- ItemNames[NameCount]= prompt("What are the names of your items","");
- }
- while (LoopCounter<= Items)
- {
- document.write ("<tr><td>Enter the price of the " + ItemNames[count] + "</td><td><input type='text'name='"+ ItemNames[count] + "'></td></tr>");
- LoopCounter= LoopCounter+ 1;
- }
- document.write ("</table></form>");
- </script>
- <body>
- <tr><td></td><td><input type="submit" value="Submit Details" onclick=validateform()
- </body>
- </html>