homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

Form Checkbox Actions

5+ Year Member

Msg#: 3791894 posted 4:23 am on Nov 22, 2008 (gmt 0)


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!





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

Msg#: 3791894 posted 4:28 pm on Nov 23, 2008 (gmt 0)

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.


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

Msg#: 3791894 posted 8:39 am on Nov 26, 2008 (gmt 0)

Hi Stuart,

Your best bet would be Ajax.



WebmasterWorld Senior Member 5+ Year Member

Msg#: 3791894 posted 10:50 am on Nov 26, 2008 (gmt 0)

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 ?

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved