0

I need to populate an array with javascript everytime I hit a button.

Eg.: if array is {[10,2,5]} and I hit the button again it should be {[10,2,5],[6,3,4]}

Q: This could be done? Could you give me a start point?

$('#button').click(function()     {
//populating array keeping old data everytime user push button.
}

<form id="myForm">
    //data that ill go to array
    <input type="button" id="button" value="ok">
</form>
5
  • What happens if the user refreshes the page? Commented Nov 26, 2012 at 1:00
  • 1
    You mean [[10,2,5],[6,3,4]] :) Commented Nov 26, 2012 at 1:02
  • those values are just examples Commented Nov 26, 2012 at 1:03
  • Can't help with the button click handler without knowing where the new data comes from. Commented Nov 26, 2012 at 1:08
  • ok ill update the code a bit more Commented Nov 26, 2012 at 1:13

1 Answer 1

3
var myArray = [];

$('#button').click(function(){
  var newArray = [];
  myArray.push(newArray);
});
Sign up to request clarification or add additional context in comments.

1 Comment

This solved parte of my question :) Ill open new question to solve another thing now

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.