Forum Moderators: open
Would anyone know where I could get a script to do the following:
I'm setting up a mailing list and the user can either select subscribe or unsubscribe using a radio button. If they select subscribe then I need to fire off a mail to subscribe@******.com and if they choose unsubscribe the mail is sent to unsubscribe@*****.com
If anyone knows a script that can do this or a good tutorial I could check out I would be grateful for the advice.
Thanks in advance.
<input type="radio" value="subscribe" name="sub" onclick="adjustAction(this.value)>
<input type="radio" value="unsubscribe" name="sub" onclick="adjustAction(this.value)>
Typos aside, etc. (I'm about to go to bed) the code above should be adaptable to your needs.
Kaled.
function adjustAction(rb)
{ rb.form.action="mailto:" + rb.value + '@domain.com';
}
<input type="radio" value="subscribe" name="sub" onclick="adjustAction(this);">
<input type="radio" value="unsubscribe" name="sub" onclick="adjustAction(this);">
Incidentally, you should wrap the radio buttons in <label> tags. This way, clicking the label activates the control.
e.g.
<label><input type="radio" .....>subscribe</label>
Kaled.
Thanks for all the help. I've had to sit back and look at it and probably didn't describe very well what I wanted to do. I should have said that I'll be using formail to process the form using the following:
<form action="/cgi-bin/formmail.pl" method=post>
<input type=hidden name="recipient" value="subscribe@thisdomain.com">
So what I need to do is change the value of the "recipient" depending on the radio button (subscribe or unsubscribe) selected by the user.
My javascript is not strong so I'm not sure if I have made it easier or more difficult.
Thanks Again.
<input type=hidden name="recipient" id="recip" value="subscribe@thisdomain.com">
That should do it. (Don't forget to adjust the onclick values to reflect the change of function name).
Kaled.