- Read a message string from a text box ("Input 1").
- Read a number from a second text box ("Input 2").
- Display, in the page footer, the message string from "Input 1". Repeat the string the number of times your program read from "Input 2". Note: Convert the value from "Input 2" into an integer by using the parseInt() function.
My instructor commented on what I did by saying this:
var value1 = document.getElementById("input1");
var value2 = document.getElementById("input2");
var footer = document.getElementById("footer");
You then use the value function to get the value of the field so that you can manipulate it. Next, you will need a for loop to display whatever was stored and accumulate value1 content i.e., inputstring 'count' number of times. For this you need a collector variable i.e., a variable for storing value1 content. This collector variable must be initialized to ' ' i.e.,, empty. You then assign the value of value1 'count' number of times in a for loop.
The last step is to display the result to the footer. The command to do that is as follows:
footer.innerHTML = your_collector_variable;