Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending an email

Status
Not open for further replies.

WannaLearn

Programmer
Jul 10, 2001
210
0
0
US
Hello. I need to some help here. I have a form on my work site, on that form there is a drop-down list. Now depending on what option selected I need that form to go to a certain email address.
I though of about doing it this way:
Code:
<option value=&quot;one@addy.com&quot;>Boss</option>
<option value=&quot;two@addy.com&quot;>Supervisor</option>
<option value=&quot;three@addy.com&quot;>Associate</option>
But my boss says that on the form there is a hidden field called &quot;reciepent&quot; that has to be taken into consideration because the CGI script won't accept it otherwise.
How can I get started?
 
set value to numerical value
edit cgi script to match value with coresponding emails
 
Hereugo, what do you mean? How can I set the value to numbers?
 
<option value=&quot;1&quot;>Boss</option>
<option value=&quot;2&quot;>Supervisor</option>
<option value=&quot;3&quot;>Associate</option>

# cgi code
if ($options_value == 1) {
# send infos to boss
} elsif ($options_value == 2) {
# send infos to Supervisor
}
# etc
someone knowledge ends were
someone else knowledge starts
 
Your CGI script expects a parameter called 'recipient', otherwise it fails. So what you need to do is name the select menu 'recipient'. The CGI script doesn't care whether the field is of type 'hidden' or 'select', so you shouldn't have to alter the CGI script at all.
Code:
<select name=&quot;recipient&quot;>
<option value=&quot;one@addy.com&quot;>Boss</option>
<option value=&quot;two@addy.com&quot;>Supervisor</option>
<option value=&quot;three@addy.com&quot;>Associate</option>
</select>
 
good thinking someone knowledge ends were
someone else knowledge starts
 
Petey, does this mean that if I add <select name=&quot;recipient&quot;> in the <form>, the form will be mailed to any one paticular person from the drop-down choice? I do not have to change the CGI script at all? And it doens't matter about the &quot;reciepent&quot; hidden field?
Thanks for all the help.
 
Correct!

CGI scripts don't care what kind of form fields the data came from; it only affects how the user interacts with the form.

For example:

<input type=&quot;hidden&quot; name=&quot;foo&quot; value=&quot;bar&quot;>

<input type=&quot;text&quot; name=&quot;foo&quot; value=&quot;bar&quot;>

<input type=&quot;password&quot; name=&quot;foo&quot; value=&quot;bar&quot;>

<textarea name=&quot;foo&quot;>bar</textarea>

<select name=&quot;foo&quot;>
<option value=&quot;bar&quot; selected>
<option value=&quot;bla&quot;>
</select>

<input type=&quot;radio&quot; name=&quot;foo&quot; value=&quot;bar&quot; checked>
<input type=&quot;radio&quot; name=&quot;foo&quot; value=&quot;bla&quot;>

<input type=&quot;checkbox&quot; name=&quot;foo&quot; value=&quot;bar&quot; checked>

...all send the same data to the CGI script, if left unchanged by the user. The difference is the level of control the user has over the values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top