HTML Form help

Associate
Joined
6 Nov 2006
Posts
722
Location
Devon
I have an email list that I want to let people subscribe or unsubscribe to by filling in their email address and clicking the relevant button - subscribe or unsubscribe. At the moment this is handled by two separate input boxes as follows
Code:
<form action="subscribe address" method="post">
Subscribe to our email list:
<input type="text" name="email" /> 
<input type="submit" value="Subscribe" />
</form>
<form action="unsubscribe address" method="POST">To*unsubscribe enter your email address:
<input type="TEXT" name="email" size="30" /> 
<input type="SUBMIT" name="UserOptions" value="Unsubscribe or edit options" /> <input type="HIDDEN" name="language" value="en" /></form>

where I've substituted the URLs for the subscription and the unsubscription with subscribe address and unsubscribe address. Is it possible to get rid if the second input box and have one box and two buttons, and if so which bits do I need to change?

I hope that makes sense

Thanks
 
Simple solution ...
<code>
<form action="" method="post" id="frmMailing">
<input type="HIDDEN" name="language" value="en" />
Email: <input type="text" name="email" />
<input id="rdoSubscribe" type="radio" name="subscription" value="Subscribe" /> Subscribe
<input id="rdoUnsubscribe" type="radio" name="subscription" value="Unscubscribe" />Unsubscribe
<input type="button" value="Go" onclick="processForm()"/>
</form>
<script type="text/javascript">
function processForm()
{
if (document.getElementById("rdoSubscribe").checked == true)
{
document.getElementById("frmMailing").action = "subscribe address";
}
else if (document.getElementById("rdoUnsubscribe").checked == true)
{
document.getElementById("frmMailing").action = "unsubscribe address";
}

document.getElementById("frmMailing").submit();
}
</script>
</code>
 
The above post has the right process.

I would put some weight on not doing it in Javascript, but whatever server side language you are already using.
 
Back
Top Bottom