Ok I know this may not be the place but anyway I need help with form web technique/ java script:

example:
I have the following form:
<form action="submit.php">
1. please enter your name: <input type="text" name="name1">

generate more new field: <input type="text" name="morefield">
<input type="submit" name="generate more fields">

</form>

ok I need a java script help so that when people put value 2 at morefield the form will automatically add 2 more empty field asking for enter name (name2, name3)

I know that I can do this with 2 php form
1 form ask for how many people, 2nd form generate the n fields as entered at form 1.
but what happen when I try to add more people at form 2? that will required some how I need to store that huge variable from form to form. If I have a huge list, and I need to add again and again it will be very difficult.

can anyone give some good tips to solve this?

    You're looking at heavy DHTML which is going to be way beyond your simple JavaScript stuff. What might be well worth considering is to have a onBlur= that does a submit, and have the page reload with a

    for ($i = 0; $i < $morefield; $i++)
    echo ($i+1).". please enter yor name: <input type=\"text\" name=\"name".($i+1)."\" value=\"".{"name".($i+1)}."\">\n";

    or something to that extent (terrible coding, I know 😉 But at least that will probably "restore" the page's content, and your users won't notice too much of a slowdown, and best of all, no complex DHTML that you'll have to worry about all night how to make it cross-browser compatible.

    Hope this helps 😉

      Write a Reply...