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>
Joseph
120k31 gold badges186 silver badges238 bronze badges
asked Nov 26, 2012 at 0:59
noneJavaScript
8453 gold badges22 silver badges41 bronze badges
1 Answer 1
var myArray = [];
$('#button').click(function(){
var newArray = [];
myArray.push(newArray);
});
answered Nov 26, 2012 at 1:01
ahren
17k5 gold badges52 silver badges70 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
noneJavaScript
This solved parte of my question :) Ill open new question to solve another thing now
lang-js
[[10,2,5],[6,3,4]]:)