Solved

Form Creation - Add additional fields to a form

Posted on 2001-06-02
5
202 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Comment from expert accepted as answer.

Thank you
Computer101
E-E Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
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 …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now