-2

I have an assignment for my course I am battling with. I have to save user input (from answers to 9 math problems) into an array when the "submit" button is clicked and then use the array to perform functions like checking how many answers are correct and showing hit rate. I have written the html with a table and form combination but not sure how to start with the javascript. Thanks!

3
  • 1
    arrays can be instatiated using [] ... added to using .push ... there's a start Commented Jan 5, 2017 at 3:34
  • stackoverflow.com/questions/10523200/… this should help you get started Commented Jan 5, 2017 at 3:35
  • If you're going to ask here, may add well share your html thus far. Commented Jan 5, 2017 at 3:36

1 Answer 1

0

Give id to all text box like this I have included one text box, You can include it how much ever u want

<input name="text" type="text" maxlength="512" id="answer1" />

<button onclick="myFunction()">Submit</button>
function myFunction(){
var array= [];
var value = document.getElementById('answer1').value
array.push(value);
for(int i=0; i< array.length; i++){
    //perform your operations
}}
Sign up to request clarification or add additional context in comments.

Comments

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.