Solved

Form Creation - Add additional fields to a form

Posted on 2001-06-02
5
207 Views
Last Modified: 2013-12-25
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
Comment
Question by:badjuju1
5 Comments
 
LVL 8

Expert Comment

by:bebonham
ID: 6152967
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
 
LVL 8

Accepted Solution

by:
bebonham earned 50 total points
ID: 6169878
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
 
LVL 2

Expert Comment

by:curri
ID: 6285408
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6699433
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
 
LVL 1

Expert Comment

by:Computer101
ID: 6903860
Comment from expert accepted as answer.

Thank you
Computer101
E-E Moderator
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question