...

View Full Version : count related input values!



blk
12-09-2004, 03: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>

</HEAD>

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


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

<TR>
<TD align=left>Number of Items</TD>
<TD width="84"><INPUT maxLength=55 size=10 name=number></TD></TR>
<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>

</TR>
<TR>

<TD></TD></TR>
<TR>
<TD></TD></TR>
<TR>

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

</TABLE>
</FORM>
</BODY>
</HTML>

A1ien51
12-09-2004, 05:09 PM
Answered Here:

http://webxpertz.net/forums/showthread.php?p=169083#post169083

Eric

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

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

Kor
12-10-2004, 11: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"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum