To access a form element with JavaScript, assign a name to the id attribute of the element you want to access.
For example, if the value of a text box needs to be accessed, set up the id attribute as follows:
input type='text' name='FirstName' id='FirstName'
Then use the JavaScript function getElementById() to access the value of the 'FirstName’'box, as follows:
var strFirstName = document.getElementById('FirstName').value;
Filed under: Internet, JavaScript, Programming, Software, Web