Javascript foreach input in form for Name and Value

sahs

New Member
I am just practicing some javascript and i used to use JQuery a lot! I have had no major experience with raw javascript and i want to learn it just as i did JQuery. I have a simple form and a javascript function to go with it onsubmit and i want to get the name and value of each input in the form with my function but it doesnt seem to work can someone help me out?\[code\]<!DOCTYPE html><html><head> <title>Foreach Practice</title> <script type="text/javascript"> function Get() { var Form = document.getElementById('Form'); for(I = 0; I < Form.length; I++) { var Value = http://stackoverflow.com/questions/15869897/this.attribute('name').value; alert(Value); } } </script></head><body><form id="Form" onsubmit="return false;"> <input type="text" name="User" placeholder="Username" /> <input type="password" name="User" placeholder="Password" /> <input type="submit" name="Submit" onclick="javascript:Get();" /></form></body></html>\[/code\]
 
Back
Top