On failed form submission, prevent change to dropdown option (Javascript, Jquery) - javascript

I am working towards the tech degree at team treehouse and my 3rd project is to make a form interactive. I'll explain my issue in point form to make it easier.
Credit card payment method needs to be selected on page load
Change this method to Paypal but do not fill out all the required fields and hit submit
Payment option reverts back to credit card but still shows paypal info
if anyone could point me in the right direction as to how to keep the paypal option selected on an unsuccessful form submit that would be awesome.
Here the link to my code: https://github.com/Allan-Glasier/InteractiveForm

I'm not sure what the Paypal info was shown, but you can use this info to initialize the selected option on page load event. For example:
$(function(){
//Get if the displayed info is for Paypal
if($("div#<Paypal info div id>").is(":visible"){
//Set Paypal option selected
....
}
})

Related

Customize PayPal Donate button to pass info through to PayPal page

I have a requirement to capture some info about a donation before the user is redirected to the payPal page, and to pass some of that info through to the page. The three main things is the amount, currency, and whether or not it should be a reoccurring payment. We want to have the user specify that detail before clicking "Donate", and then have that info sent through to PayPal to repopulate the page.
I have managed to achieve some of this by using the "Buy now" button, instead of the "Donate" button, and just displaying the Donate image. With that I can pass through the amount and currency, but can't set reoccurring payment it seems. At least, I don't know what the form input should be called for that option to take effect on the PayPal side. In order to do this, I had to set a couple of options when creating the "Buy now" button. I think the one was to not keep inventory or something like that, and on the page where I can copy the HTML I had to effectively unlock it. But there are no such options on the Donate button creation flow. So when I try to pass amount or currency through to the Donate page, it doesn't do anything.
I tried removing the button_id hidden input, but that just breaks the whole thing.
Is there any way for me to capture those three pieces of information - amount, currency, and whether or not it should be a reoccurring payment - on my site and pass it through to the PayPal screen upon redirect?
If you want to specify that a payment should be recurring, then the checkbox on your site that makes the donation recurring will need to convert the button into a completely different type-- a "Subscriptions" button. That is the only way for you to specify that something is recurring before the buyer reaches PayPal.
The other way of starting with a Donate transaction and having it become recurring, only works for:
transactions of type Donate (not Buy Now)
when the amount is NOT pre-specified before redirecting them
when the user selects this recurring checkbox at PayPal
All three conditions are necessary and required for this type of recurring donation to be possible.

When Gravity Form is submitted then reveal content on same page

Using Wordpress with Divi Theme.
When Gravity Form submit button is pressed and submitted I also want it to reveal a section on the same page. Like a toggle reveal that submits the form at the same time.
I Enabled AJAX so the page doesn't refresh after submission but don't know how to reveal a section of page and submit at the same time. Any help welcome Thanks.
There are a few ways to do this. The easiest would be to put the section you want to reveal in the confirmation box within gravity forms. Alternatively you can have the confirmation process re-direct to a specific page that has the same information as your first page, but with the new content on it as well. Finally, (most complex but also most secure) you can setup the gravity forms to also add the user to a member group (using the "Groups" plugin), then have that groups plugin show and hide info based on group membership.

Shopify - Adding Email Form to Add-to-Cart Button

Is there a way to add some kind of form requesting the customer email address when adding to the cart?
click 'add to cart'
popup asking for email (optional)
moving forward to the cart, passing along the add to cart product info.
My understanding is that with forms, you have your action attribute which says where the form's data will be sent and that your button's type attribute of submit will execute the form's action.
I know each theme is different and some don't have a button element with type="submit" to execute the action. But with a theme like "Debut", which has a very simple add-to-cart form, how would you go about this?
Note: I don't need help creating a lighbox, but I'm confused about how to refrain from executing the cart action until the popup is finished (meanign the customer has either entered their email or chosen to decline).
Please let me know if you need any more information! Thanks

Facebook - Can't submit new Open Graph type, submit grayed out. How to submit?

I added a few Open Graph types to an app on facebook, following all the instructions. I clicked save changes and when you go to review status the Submit button next to the types is grayed out. I can't submit them, and thus they can't be used - and they can't be used until submitted and reviewed which I can't do.
The error shown when hovering the button is: You, or this app's Open Graph Test User, must have published this action before being able to submit for review.
What should I do to fix this? How do I unpublish the action to submit it (i assume that's what I need to do) and then republish it after it's reviewed?
I tried finding instructions for unpublishing an action to no avail.
EDIT: Tested with a completely new app I created, just random test name stuff. Same thing happens. I literally added an action type within seconds of creating the app, and tried to submit in review status and still the submit button is grayed out.
You haven't published those stories yet. You can publish each story using the graph API explorer (https://developers.facebook.com/tools/explorer). Part of the submission process is including a screenshot of the story published on your wall, so you need to publish one before you can submit.

Disable JS Submit Validation Checks

I don't really know how to explain this one very well so here we go.
I am trying to implement the Stripe payment button on my page. When the submit button is click, the JS validates the users input. That said, I do not have access to the JS file.
I am trying to add the ability for users to choose weather to pay by check (in which the stripe form elements disappear and other appear related to paying by check).The problem is, when the user selects to pay by check and click submit, the validation checks for the stripe form are run, they of corse fail and the submit action is aborted.
So how, when the user selects check, can I disable the Stripe actions?
Thank you in advance for any help.
You should have different forms for the different payment methods, so that the Stripe form doesn't think it is being submitted.
Here's my guess as to how you could disable the listeners, anyway:
$("#payment-form").unbind('submit');
You have a couple different options. One would be to work with the event handlers in javascript when the user chooses to pay by check. Another option (probably simpler) option would be to have 2 submit buttons and show and hide them depending on how the user intends to pay.

Categories