View Full Version : Variable recipients in Forms?
Java Nuts
05-21-2003, 08:50 PM
heya peoples. I got a question and would be greatful to anyone with help.:) I was wondering if its possible to have variable recipients in forms? I use Matts Script Archive form mail script, but I dont think that would have anything to do with it. I know you can have multiple recipients, but what about variable recipients?:confused:
my scenario:
I have a form with 3 Radio Buttons, and i want them to 'designate' who the form will go to instead of the preset option of <INPUT TYPE="HIDDEN" NAME="recipient" VALUE="me@mysite.com">
any advice or help? I would greatly appreciate any! And thanks in advance!:D :cool:
Vladdy
05-21-2003, 08:54 PM
Using onsubmit event see which radio is checked and set form action accordingly.
Java Nuts
05-21-2003, 09:18 PM
doesnt that require a script? sorry, i should've mentioned, i dont know much about that kind of stuff.
thanks for that though, just wondering if it requires a script of some sort, because i have other Onsubmit things for different pages and I dont know how to write up scripts
cheesebagpipe
05-22-2003, 01:08 AM
<input type="radio" name="recipient" value="mailto:me@mysite.com" onclick="this.form.action=this.value">
<input type="radio" name="recipient" value="mailto:you@yoursite.com" onclick="this.form.action=this.value">
Probably want to use a validator for the button set.
Java Nuts
05-22-2003, 03:39 AM
ah cool:cool: thanks guys. but do you know if there is a way to do it through the cgi script instead of using mailto? just wondering, since this form i'm making up will be used by my family and when that window pops they get confused. :p lol, just trying to make it simple for them. and i think the onlymail they use is hotmail or yahoo, they dont have outlook or anything.
thanks though! you guys rock!:D :thumbsup:
Java Nuts
05-22-2003, 03:48 AM
btw, heres the basic code with the added 'mailto' & 'onclick' added, if its any help:
<FORM ACTION="http://www.mysite.com/cgi-bin/FormMail.pl" METHOD="POST">
<INPUT TYPE="HIDDEN" NAME="redirect" VALUE="main.html">
<INPUT TYPE="HIDDEN" NAME="print_config" VALUE="email,subject">
<input type="radio" name="Recipient" value="mailto:email1@mysite.com" onclick="this.form.action=this.value">
<input type="radio" name="Recipient" value="mailto:email2@mysite.com" onclick="this.form.action=this.value">
<INPUT TYPE="SUBMIT" VALUE="SEND IT!" class="inputtext"> </FORM>
cheesebagpipe
05-22-2003, 04:40 AM
Not up on Matts Script Archive, but try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>untitled</title>
</head>
<body>
<FORM ACTION="http://www.mysite.com/cgi-bin/FormMail.pl" METHOD="POST" onsubmit="alert(recipient.value);return false;">
<INPUT TYPE="HIDDEN" NAME="redirect" VALUE="main.html">
<INPUT TYPE="HIDDEN" NAME="recipient" VALUE="me@mysite.com">
<INPUT TYPE="HIDDEN" NAME="print_config" VALUE="email,subject">
<b>Recipient:</b>___
<select name="choose_recipient" onchange="recipient.value=this.options[this.selectedIndex].value">
<option value="me@mysite.com" selected="selected"> me ! </option>
<option value="email1@moms_isp.com"> mom </option>
<option value="email2@dads_isp.com"> dad </option>
</select>_____
<INPUT TYPE="SUBMIT" VALUE="SEND IT!" class="inputtext"> </FORM>
</body>
</html>
[red bit is for demo]
Java Nuts
05-22-2003, 09:10 PM
ah thanks! :thumbsup: I tried it, but it wouldn't work quite right, so then I messed around with some of it and made it work the way I wanted it to: (thanks to everyone for the help, its greatly appreciated! :D )
<FORM ACTION="http://www.mysite.com/cgi-bin/FormMail.pl" METHOD="POST" OnSubmit="submit(recipient.value);return false;">
<INPUT TYPE="HIDDEN" NAME="recipient" VALUE="[this.selectedIndex]">
<INPUT TYPE="HIDDEN" NAME="redirect" VALUE="main.html">
<INPUT TYPE="HIDDEN" NAME="print_config" VALUE="email,subject">
Designated To:
<INPUT type="radio" name="recipient" value="Family1@mysite.com" oncheck="recipient.value=this.options[this.selectedIndex].value">
Family Member 1
<INPUT type="radio" name="recipient" value="Family2@mysite.com" oncheck="recipient.value=this.options[this.selectedIndex].value">
Family Member 2
<INPUT TYPE="SUBMIT" VALUE="SEND IT!"></FORM>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.