Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Form Creation - Add additional fields to a form

Posted on 2001-06-02
5
Medium Priority
?
217 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to count occurrences of each item in an array.
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 …
Suggested Courses

618 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