homepage Welcome to WebmasterWorld Guest from 54.161.247.22
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
getElementById('form') to get form items
HeadBut




msg:3067793
 7:04 pm on Aug 31, 2006 (gmt 0)

is it possible to getElementById('form') then get form inputs? Looking for an example for a dynamic form with a dynamic number of form inputs?

Thanks

 

Fotiman




msg:3067824
 7:20 pm on Aug 31, 2006 (gmt 0)


<form id="myForm" action="">
<div>
<input name="foo">
<input name="bar">
<input name="xyz">
</div>
</form>
<script type="text/javascript">
function getFormItems()
{
if(!document.getElementById ) return;
var f = document.getElementById( 'myForm' );
// Step through the form elements
for( var i = 0; i < f.elements.length; i++ )
{
alert( f.elements[i].name );
}
}
getFormItems();
</script>

Hope that helps.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved