Last active
October 29, 2016 15:12
-
-
Save lena121/589b2c1a4e4f7a56f5e73993b58426ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name='myform' id="formID"> | |
Name <input type="text" name='nameInput' value='enter your name' class="foo"> | |
Email <input type="text" name="emailInput" value="enter your email"> | |
<input type="submit" name="submitBtn" value="Submit"> | |
<p></p> | |
</form> | |
--- get form element on page: by ID attribute, by value of form's attribute 'name' | |
document.getElementById("formID") | |
document.myform | |
--- get all elements in form | |
document.getElementById("formID").elements | |
document.myform.elements | |
for(var i=0; i< form.elements.length; i++){ | |
var el = form.elements[i]; | |
// get all attributes of inputs-elements | |
el.type (text, button, submit, reset, radio, select, checkbox) | |
el.value (value of 'value' attribute) | |
el.name (value of 'name' attribute) | |
el.form.name (gets value of name's form attribute, where is element contains) | |
} | |
--- get particular form's element by its value of 'name' attribute | |
document.getElementById("formID").submitBtn | |
document.myform.submitBtn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment