I don't have your HTML, so I'm just going to be using elements which I think you will have within your document
.
Test this out:
Pure JavaScript:
var form = document.getElementsByTagName("form")[0];
form.onsubmit = function(){ // on form submit
var input = document.querySelectorAll("input");
for(var i = 0; i < input.length; i++){ // loop through each input on the page
alert(input[i].value); // will alert the value of the input
}
return false; // stop form from posting
}
jQuery:
$("form").submit(function(){ // on form submit
$("input").each(function(){ // foreach input
var value = $(this).val(); // grab its value
alert(value); // output its value
});
return false; // prevent form from posting
});
So when the form submits, it will iterate through each input
, and output each value through an alert
.
Hope this helps! :-)