If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

dynamic form displays variable number of new text fields

Hello,

I am thomas. This is my first post!

I have a question. I am trying to make a dynamic form. I have seen this addressed in a few other threads, but it is first of all not exactly like my problem and also, the language of the explanations is not simple enough for me to understand.

I am trying to make a form that has 1 box that asks how many designs a customer wishes to order, then based upon that number, reveals that many pairs of text boxes below; one should be with the label, «name of design», while the other should be with the label «quantity of design». That way, if a user enters 4, four pairs of these boxes will appear, asking him specific names and quantities

If I set up a variable quantity to the value of the text box, I think I should be able to loop like,

for x=1; x<=qty.value; x++

but then I am confused about how to make the thing render the text boxes. My primitive knowledge tells me I could do something like document.write. But on another thread I read I saw that I could also use

document.createElement('input');
setAttribute('type', 'text');

Something like that seems a bit more sophisticated (or at least like it would work at all), but I am so confused about how to put it all together.

I am very grateful if someone can take the time to shed some light on a solution to this problem.