- Forums
- Javascipt
- How To Get Field Id Value With Javascript By Id Name
if you want to learn how to get field id value with javascript i wills show you today on this page [813], Last Updated: Sat May 18, 2024
wallpaperama
Tue Jan 20, 2009
3 Comments
14676 Visits
if you want to learn how to get field id value with javascript i wills show you today, if you followed my tutorial before
http://www.wallpaperama.com/forums/how-to-get-value-from-a-form-field-with-javascript-t7009.htmlok, well, if you want to get the value by id then its easy here is the javascript code that makes it all happen:
getElementById()
so here is the code you can use as an example i made for you. just copy and save it as javascript.html and then open it with your browser
<script type="text/javascript" charset="iso-8859-1">
function validate_form2(form) {
var user_name = document.getElementById('user_name').value;
window.alert('Hi '+user_name);
}
</script>
Enter your name and then hit submit
<form action="" method="post" onsubmit="return validate_form2(this);">
<input name="form[]" id="user_name" type="text" value="">
<input type="submit" value="Submit">
</form>
DEMO
Enter your name and then hit submit