Accessing HTML Input Elements from JavaScript
Assuming you don't have other elements with the same name, you can get input values ββfrom JavaScript by name as follows:
var firstName = document.getElementsByName("firstname")[0].value;
Now you have the value from the firstname field in the JavaScript variable named firstName. Just keep repeating and you have received other input fields. Then you can continue and bind these operators to the function and call it when the input changes. For example:
function formChanged() { var firstName = ... var lastName = ... }
Now register this function call for keyup changes / events, and you have a function that tracks the change of form values:
<input type="text" name="firstname" onkeyup="formChanged()" onchange="formChanged()"/>
jsalonen
source share