rendered paste body<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Tell a friend Script</title><!-- The styles below are for positioning and table-less-ness of the form --><style type="text/css"> *, html, body { font-family: Arial, sans-serif; font-size: 12px; } label,input, textarea { display: block; width: 200px; float: left; margin-bottom: 10px; padding-right: 20px; } label { text-align: right; width: 200px; } br { clear: left; } ol { list-style: none; padding: 0; margin: 0; text-indent: 0; } li{ clear: left; list-style-type: none; padding: 0; margin: 0; text-indent: 0; }</style><script language="JavaScript" type="text/javascript">function add_friend() { var friend_ol = document.getElementById( 'friend-list' ); // Create the new LI var new_li = document.createElement( 'li' ); // Create the input for it var li_input = document.createElement( 'input' ); var new_label = document.createElement( 'label' ); var tellafriend = document.forms['tellafriend']; //var femails = tellafriend.elements['femail[]']; //var nbrOfFriends = femails.length; //var nbrOfFriends = tellafriend.elements['femail[]'].length; var nbrOfFriends = document.getElementsByName("femail[]").length; var nbrForShow = nbrOfFriends + 1; new_label.appendChild( document.createTextNode( "nbrForShow="+nbrForShow ) ); li_input.className = 'input-text'; li_input.name = 'femail[]'; // Add the text input to the LI new_li.appendChild( new_label ); new_li.appendChild( li_input ); // Add it to the LI friend_ol.appendChild( new_li ); } </script></head><body><form id="tellafriend" method="post" action="tell.php"> <label><b>Friend #1 email:</b></label> <input name="femail[]" id="femail1" size="25" type="text"><br /> <label><b>Friend #2 email:</b></label> <input name="femail[]" id="femail2" size="25" type="text"><br /> <br /> <ol id="friend-list"> </ol><br /> <label>Have more friends?</label> <input type="button" class="clear" onclick="add_friend();" value="Add another friend" /><br /> <br /></form><script language="JavaScript" type="text/javascript"> add_friend();</script></body></html>