?
Solved

Form Creation - Add additional fields to a form

Posted on 2001-06-02
5
Medium Priority
?
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

764 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