Welcome to WebmasterWorld Guest from

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

Form Checkbox Actions



4:23 am on Nov 22, 2008 (gmt 0)

10+ Year Member


I'm setting up a basic email form which when completed sends the entered details to a specified email address, I have no problems with this form, however I want to add a checkbox which when clicked submits a different CGI script and adds the user to our mailing list.

This is the email form:

<form action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="POST">
<div align="left">
<input type="hidden" name="recipient" value="test@test.com">
<input type="hidden" name="subject" value="Competition Entry">
<input type="text" name="name" size="40" style="width: 300px">
<br />
<input type="text" name="email" size="40" style="width: 300px">
<br />
<input type="checkbox" name="subscribe" value="subscribe" checked="checked">
Join Mailing List<br>
<input type="submit" value="Send">

And this is our subscribe form:

<form method="post" target="myNewWin" action="http://scripts.dreamhost.com/add_list.cgi">
<input type="hidden" name="list" value="subscribe" />
<input type="hidden" name="domain" value="domain.com" />
<input type="hidden" name="emailit" value="1" />
Name: <input name="name" size="28"/>
Email: <input name="email" size="28"/>
<input type="submit" name="submit" value="Subscribe" onClick='sendme();' />

If someone knows how to basically make the checkbox execute the bottom piece of code when submitted that would be very much appreciated!




4:28 pm on Nov 23, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

The best solution would be to incorporate the two scripts into one, or add an exec command to one script that passes the variables to the second script. You could do something with Javascript, but then it would fail with JS disabled.


8:39 am on Nov 26, 2008 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Hi Stuart,

Your best bet would be Ajax.



10:50 am on Nov 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I would go with an onclick handler on the submit button with code to change the action,target etc based on the state of the checkbox.

Ajax would give you more flexabilty in mapping field names and values but may not be required in this case ?


Featured Threads

Hot Threads This Week

Hot Threads This Month