var in javascript form code example Example: using html forms to define javascript variables var firstName = document.getElementsByName("firstname")[0].value;