Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

getElementById('form') to get form items



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

10+ Year Member

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?



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

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

<form id="myForm" action="">
<input name="foo">
<input name="bar">
<input name="xyz">
<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 );

Hope that helps.


Featured Threads

Hot Threads This Week

Hot Threads This Month