homepage Welcome to WebmasterWorld Guest from 54.198.8.124
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
stuleech




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

Hi

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">
Name:
<input type="text" name="name" size="40" style="width: 300px">
<br />
Email:
<input type="text" name="email" size="40" style="width: 300px">
<br />
<input type="checkbox" name="subscribe" value="subscribe" checked="checked">
Join Mailing List<br>
<br/>
<input type="submit" value="Send">
</div>
</form>

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"/>
&nbsp;
<br/>
Email: <input name="email" size="28"/>
<br/>
<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!

Thanks

Stuart

 

rocknbil




msg:3792490
 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.

dreamcatcher




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

Hi Stuart,

Your best bet would be Ajax.

dc

daveVk




msg:3794574
 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