<table>
<tr>
<td>Enter the Input</td>
<td><input type="text" id="inputtext" /></td>
</tr>
<tr>
<td></td>
<td><button type="button" id="add" onclick="addRecord();">Add </button>
<button type="button" id="display" onclick="displayRecord();">Display</button>
</td>
</tr>
</table>
I need to take input from the user, when user clicks on the Add button after entering data in the Textbox. User may add 'n' number of inputs which I do not know. I need to store the inputs in an array and display it on clicking the Display button. How should that be done? I tried using push(), however it doesn't work:
function addRecord()
{
var add= document.getElementById("add");
var addArray= [];
addArray.push(add.value);
}
addArrayand assigning it the value of[]in theaddRecordmethod. This will clear the array and push anadd.valueevery time it fires. DefineaddArrayoutside of that method.