Question about forms

T

tracy.cooperjr

Is it possible to have a form that can be sent to 1 of 3 different
addresses depending on which selection from a drop-down they have
selected.

Example:
A user fills out a survey and then can select one of three recipients
of that survey and it will be sent to only that one person and not the
other two as well.
 
M

Martin Jay

In message said:
Is it possible to have a form that can be sent to 1 of 3 different
addresses depending on which selection from a drop-down they have
selected.

Example:
A user fills out a survey and then can select one of three recipients
of that survey and it will be sent to only that one person and not the
other two as well.

Yes, that's possible. But it has to be done by a script on your server.

In your HTML form you'd have something like this to create the drop-down
box:

<select name="email">
<option value="1">Email address 1</option>
<option value="2">Email address 2</option>
<option value="3">Email address 3</option>
</select>

And then in the script that receives the form you would use logic such
as like:

if name = 1 then email form to (e-mail address removed)
if name = 2 then email form to (e-mail address removed)
if name = 3 then email form to (e-mail address removed)
 
J

Jukka K. Korpela

Martin Jay said:
In your HTML form you'd have something like this to create the
drop-down box:

<select name="email">
<option value="1">Email address 1</option>
<option value="2">Email address 2</option>
<option value="3">Email address 3</option>
</select>

Any <select> element (except those with the 'multiple' attribute set) should
have one option preselected, normally a "dummy" option, to avoid getting
browser-dependent default data if the user does not make any selection and
to avoid defaulting to the first option even when you don't mean that.
Therefore, add the following as the first option:

And then in the script that receives the form you would use logic such
as like:

if name = 1 then email form to (e-mail address removed)
if name = 2 then email form to (e-mail address removed)
if name = 3 then email form to (e-mail address removed)

Well, you would probably want to test "email" (the actual field name) rather
than "name".

In actual programming, you would probably want to use an array or a hash of
addresses and simply pick up an address using "email" as an index to it -
_after_ checking that the value is an integer that is within the specified
bounds.

And you may wish to check against the case where "email" is none of 1, 2,
and 3. The value 0 should probably be treated gracefully as a user input
error. Other values might be treated as potential cracking attempts, so the
implicit error processing of not doing anything (data ignored, no data sent
anywhere) might be quite adequate.

P.S. I have an uncanny feeling that the OP wanted to do the job without any
kind of server-side scripting. Then the answer is "don't".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top