careyd Posted May 29, 2015 Share Posted May 29, 2015 Inside of a <form>, is the input name=( fieldname1 ) able to be addressed in JavaScript as a variable? such as {fieldname1 == fieldname2} Link to comment Share on other sites More sharing options...
Ingolme Posted May 29, 2015 Share Posted May 29, 2015 You have to access the element using DOM methods. The easiest way is to give the element an ID. Once you have the element, you have to use the value property to get the user's input. HTML <input id="form-input" type="text" name="field-name"> Javascript // Get the elementvar element = document.getElementById("form-input");// Get its valuevar value = element.value;// Do something with the value, for example:if(value == "something") { // Do something} Link to comment Share on other sites More sharing options...
careyd Posted May 29, 2015 Author Share Posted May 29, 2015 THANK YOU! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now