I have an input
<input type="text" value="hello" />
and I want to get the value of this and using Jquery, save the value in an array.
How can I do this???
I have an input
<input type="text" value="hello" />
and I want to get the value of this and using Jquery, save the value in an array.
How can I do this???
var formValues = $('#your_form').serialize();
var formValuesAsArray = $('#your_form').serializeArray();
To get the value from your input, you should give it a name
attribute; for example <input type="text" name="message" />
and get its value by $('input[name=message]').val()
you could run this code for submitting:
$('formname').submit(function() {
alert($(this).serialize());
return false;
});
This would return a string like:
a=1
You could then save this to an array.
using jQuery,
$(document).ready(function(){
var arr = [];
arr.push($('#inputID').val());
})
you should give your input an id
<input type="text" value="hello" id="inputID" />