• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Form Creation - Add additional fields to a form

I want to create a form that will allow users to dynamically add new fields to a form.

For example: Let's say I have a form that allows someone to enter their email address to have a catalog sent to them. The default form will only have fields for one address only.

At the end of that form, it will ask if they want to enter additional email addresses. If they choose to, they will click a box and a new address field will appear and they can add more addresses.

One stipulation is there is no limitations to the number of email addresses they can enter. So if they continue checking the box at the end of each email field, a new email box will appear.

Here's a quick sample.

Thanks!!!


<HTML>
<HEAD>
<TITLE>FIRST FORM </TITLE>
</HEAD>
<BODY>

<FORM ACTION="test2.cgi" METHOD = "POST">
 FIRST NAME: <INPUT NAME="FIRST" TYPE=TEXT SIZE = 25><BR>
 LAST NAME: <INPUT NAME="LAST" TYPE=TEXT SIZE = 25><BR>
 EMAIL: <INPUT NAME="EMAIL" TYPE=TEXT SIZE = 30><BR>
 Enter another email address? <INPUT NAME="more" TYPE=checkbox><BR>
<INPUT TYPE=SUBMIT VALUE="TEST IT">
</FORM>

</BODY>
</HTML>
0
badjuju1
Asked:
badjuju1
1 Solution
 
bebonhamCommented:
try asking in the javascript topic area.

also, just so you know, you will have to store all the addresses in a variable and then pass them back to your script...

you will not be able to display all the email addresses at the same time.

try posting in javascript ta for more info.

Bob
0
 
bebonhamCommented:
the problem is that netscape 4 doesn't support dynamic document additions.  I'm not quite clear whether 6 does or not...but that doesn't matter because if you want to support netscape, you need to support 4

anyhow, so you'd have to prepare as many divs as you'd want to have email addresses


here is another option...
var i=0
var earr= new Array()
function mul()
{
i++
mitem=prompt('enter an item, or leave blank to end')
if(mitem != '' && mitem != 'undefined' && mitem!= null)
{
earr[i]=mitem
setTimeout("mul()",100)
}
}


that will pop up a prompt that they can enter the email address in and keep doing it untill they enter a blank in any browser.

also, it will put all the email addresses in an array called earr

you can then access them and send them to the server (if you need help with this part, post a question in the javascript topic area)

to start the process, call the function mul()

you can do it from the onclick of a input button like this

<INPUT TYPE="BUTTON" ONCLICK="mul()">

hope that helps,

ask if you are unclear.

Bob
0
 
curriCommented:
I think bebonham already answered, but just a quick suggestion.

Why do that ?

You can ask the user to enter e-mails separated by commas or semicolons or whatevers. Then you split that string into the individual addresses in your cgi program.

Orlando
0
 
MoondancerCommented:
Please update and/or finalize this question.  Check the ALL TOPICS link below to see if another topic area may fit a bit better to your question and perhaps posting a pointer question to this one will help.

Moondancer
Community Support Moderator @ Experts Exchange
0
 
Computer101Commented:
Comment from expert accepted as answer.

Thank you
Computer101
E-E Moderator
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now