View Full Version : count related input values!

12-09-2004, 02:35 PM
I need to write a javascript function. There are two fields "Number of Items" and "Item ID". "Item ID" has 5 input fields. If the field "Number of Items" is chosen as 1, then "Item ID" needs 1 Id input. If the "Number of Items" is 2, 2 ID inputs are needed and so on. Could anybody help me in writing this function please. Thanks in advance.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Accomodation form</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR>


<BODY vLink=#006600 link=#3333ff bgColor=white>

<FORM action=" " method=post>
<h1>Enter the details</h1>
<TABLE cellSpacing=0 cellPadding=0 border=0>

<TD align=left>Number of Items</TD>
<TD width="84"><INPUT maxLength=55 size=10 name=number></TD></TR>
<TD align=left>Item ID</TD>
<TD width="84"> <input name=id_1 size=10></TD>
<TD><input name=id_2 size=10></TD>

<TD><input name=id_3 size=10></TD>

<TD><input name=id_4 size=10></TD>

<TD><input name=id_5 size=10></TD>



<TD width="200"><INPUT type=submit value=Submit><INPUT type=reset value="Clear Form">


12-09-2004, 04:09 PM
Answered Here:



12-10-2004, 10:40 AM
Hi A1ien51,

Thanks for the code but it is not working :-(

12-10-2004, 10:47 AM
It is not so difficult, but before answering, I would like to know... But if the user inputs 6? or a letter? Wouldn't it be easier to use a select with preset options values?

By the way, I guess you forgot to specify the type of the input elements. I presumed that they are all type="text"