View Full Version : dynamic number of input fields??

10-25-2003, 11:17 PM

I wonder if there is a way to let the client
choose the number of inputs he/she wanna do?

For example, I'm trying to make a signup page where
a team can type in the number of players they
have to represent them in a golf tournament so if they
type in 6 in that field then there will be 6 fields
where to type there names for saving to a database.

If there is a way, how would the code for that specific
task look like??


10-26-2003, 12:17 AM
You could do that, by submittingthe form after they typed in the number, and then dynamically build the form for the names. Suppose the first form has this field with name="ammount" . Then you would have

if CInt(request.form("ammount")) > 0 then ' so if they entered a number greater then 0
your code form the form
dim i
i = 1
do while i <= request.form("ammount")
response.write("Name of player " & i & " : " )
response.write("<input type=""text"" name=""player" & i & """ />")
your other formcode
your code to redirect to the first form
end if

in the page where the form is posted to

10-27-2003, 07:29 AM
or you can do it on the client-side through JavaScript and DOM

10-27-2003, 01:30 PM
I got this somewhere and never used it



1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->


<script language="JavaScript">

function SymError()
return true;

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
return (new Object());

window.open = SymWinOpen;


<!-- Original: Peter Hermus -->
<!-- Web Site: http://come.to/speedpete -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function createForm(number) {
data = "";
inter = "'";
if (number < 16 && number > -1) {
for (i=1; i <= number; i++) {
if (i < 10) spaces=" ";
else spaces=" ";
data = data + "URL " + i + " :" + spaces
+ "<input type='text' size=10 name=" + inter
+ "url" + i + inter + "'><br>";
if (document.layers) {
else {
if (document.all) {
cust.innerHTML = data;
else {
window.alert("Please select up to 15 entries.");
// End -->

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->


<form name=counter>
Number of URLs to enter:
<input type=text name=number size=5>
<input type=button value="Update" onClick="createForm(counter.number.value);">


<form name="webform">
<table border=0>
<tr valign=top>
<td><input type=text size=20 name=name onChange="msg(this.form)"></td>

<tr><td colspan=2>

<!-- Placeholder for dynamic form contents -->
<span id=cust style="position:relative;"></span>


<tr valign=top>
<td><textarea name=comments cols=45 rows=5 wrap=virtual OnChange="msg(this.form)">
<td><input type=submit value="Send"></td>

<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>

<!-- Script Size: 1.95 KB -->

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum