Title: Adding onclick/onsubmit functionality?
Last modified: February 6, 2019

---

# Adding onclick/onsubmit functionality?

 *  Resolved [Paul Hartman](https://wordpress.org/support/users/paul-hartman/)
 * (@paul-hartman)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/adding-onclick-onsubmit-functionality/)
 * Form for community association membership and donations. I would like to add 
   the membership fee (radio buttons) plus an optional additional donation value(
   could be zero) to make a total dollar value that is sent to Paypal. Need to display
   it before user clicks submit. Is there a way to add some Javascript and onclick/
   onsubmit functions to certain fields?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-onclick-onsubmit-functionality%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [bgermann](https://wordpress.org/support/users/bgermann/)
 * (@bgermann)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/adding-onclick-onsubmit-functionality/#post-11194265)
 * Sure. That is not dependent on cformsII. Just make your JavaScript run on the
   page with the form and then you can add handlers for the form’s elements.
 *  Thread Starter [Paul Hartman](https://wordpress.org/support/users/paul-hartman/)
 * (@paul-hartman)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/adding-onclick-onsubmit-functionality/#post-11194844)
 * I was hoping for a few more hints than that, I’m not a Javascript guru. Do you
   have any examples handy?
 * Another question — When I post the form to Paypal there is no confirmation email
   sent to admin. Paypal doesn’t send most of the fields collected via the form.
   Is there any way to have cformsII send the admin email with all the info after
   Paypal completes the transaction?
 *  Plugin Author [bgermann](https://wordpress.org/support/users/bgermann/)
 * (@bgermann)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/adding-onclick-onsubmit-functionality/#post-11195588)
 * You lose all cformsII processing if you hand over the form request to PayPal.
   If PayPal exposes a REST API that signals back to you when they have processed
   the request, maybe there is a way using a cformsII hook. You would have to generate
   the API request yourself, wait for the response and then continue processing 
   in cformsII.
 * The cformsII solution to part of your problem would be using a regular expression
   on the dollar field. I do not have an example for the thing you want to do with
   JavaScript; just ask in a general JavaScript forum. You want to do something 
   like `document.getElementById("li-2-2items").addEventListener("click", function(){...})`
 *  Thread Starter [Paul Hartman](https://wordpress.org/support/users/paul-hartman/)
 * (@paul-hartman)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/adding-onclick-onsubmit-functionality/#post-11203976)
 * I have given up on doing any math magic, The site has to go live on Friday so
   I have no time.
 * The problem I am having now is I am trying to have a multi-part form. Page 1 
   sends the admin email (and stores in DB) when user clicks “Continue” button. 
   Page 2 displays the form field values then submits to Paypal when user clicks“
   Submit” button. It works until I edit Page 1 form to change something and when
   I load the page containing the form (Page 1) it skips Page 1 of the form and 
   goes right to Page 2 and displays blank fields. I have cleared caches (server
   and browser) with no effect. The “Back” button goes to Paypal instead of to Page
   1.
    [http://us222.siteground.us/~sgcpc499/donations-menu/membership/](http://us222.siteground.us/~sgcpc499/donations-menu/membership/)
 *  Thread Starter [Paul Hartman](https://wordpress.org/support/users/paul-hartman/)
 * (@paul-hartman)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/adding-onclick-onsubmit-functionality/#post-11206354)
 * I figured it out. If I delete cookies for the site in the browser it works.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding onclick/onsubmit functionality?’ is closed to new replies.

 * ![](https://ps.w.org/cforms2/assets/icon-128x128.png?rev=1010031)
 * [cformsII](https://wordpress.org/plugins/cforms2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cforms2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cforms2/)
 * [Active Topics](https://wordpress.org/support/plugin/cforms2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cforms2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cforms2/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [onclick](https://wordpress.org/support/topic-tag/onclick/)
 * [onsubmit](https://wordpress.org/support/topic-tag/onsubmit/)

 * 5 replies
 * 2 participants
 * Last reply from: [Paul Hartman](https://wordpress.org/support/users/paul-hartman/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/adding-onclick-onsubmit-functionality/#post-11206354)
 * Status: resolved