[Javascript] addin <input fields> via visibility or similar?
Triche Osborne
wdlists at triche-osborne.com
Fri Sep 9 17:16:46 CDT 2005
Michael Borchers wrote:
> i have form
> for several products.
>
> the products data is stored in arrays.
>
> normally i have about 5 rows.
>
> <select name="products_id[0][products_id]" id="products_id[0][products_id]">
> ...
> </select>
> <input type="text" name="products_id[0][products_price]" id="products_id[0][products_price]" value="0,00">
> <input type="text" name="products_id[0][products_quantity]" value="" size="6" maxlength="3">
>
> until products_id[4] of course.
>
> now i would like to have an extra input field for adding X rows and make them visible
> in the form without reloading the page.
> is this possible with visible layers or even without preloading rows and generating
> them on the fly?
Given these restrictions, the only thing I can think of is fairly
inelegant. In short:
(1) Add the maximum number of input fields that you will allow someone
to request.
(2) Assign each INPUT an intelligent (sequential) ID attribute and a
CLASS attribute styled to display: none.
(3) Create a second class style for display: inline (or block, depending
on how you're styling the rest).
(4) When someone requests X number through the input field, use the ID
fields to grab each INPUT in order and change its CLASS attribute value
to the alternate style.
I haven't tested this, but I have "added" single INPUTs for field
dependencies, so I know the CSS part is sound. Revealing multiple ones
is simply a matter of the JavaScript beginning with the initial ID and
counting up to the value entered by the user.
Triche
More information about the Javascript
mailing list