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
Related
I am new to JS. I want to have a delete button for my tickets in my cart, when I press the button it should ask if I really want to delete the ticket (JS confirm) if the user confirms then call a function to delete the ticket. I am unsure of how to determine if the user confirmed or not.
Us onclick method on button as follow
onclick="return confirm(' really want to delete the ticket?')"
I have a form, where most fields are required. Once the form is submitted series of automated tasks gets initiated.
I want to provide users the ability to save their progress and come back and complete the form.
Cookies isn't a option, as users will be logged in to their account and should be able to continue their application from different devices.
The application is saved in the database. I need to do it in a way so that submit button submits the form, checks for all the required fields. (It does this currently).
I also need to have a save progress button which will ignore the validation and just save the data currently filled. ( No automated tasks etc should run when form is saved using this button.).
Is there a way to achieve this? If so how do i go about it?
The solution above may not be the right / most effective solution. I'm open to any other suggestion.
Thank You
On the second button you can use the formaction attribute.
Please note this works only on for buttons with type="submit". Then you can send the save progress info to a different page then just store the info.
<button type="submit" formaction="saveprogress.php">Save Progress</button>
If you are having two submit buttons, 1. Submit and 2. Save Progress, then it will be very easy.
Add onClick action on Submit button to validate the form, and after complete validation(return true for correct validation) you can save the data in database.
And on Save progress, just on click of button, you can directly save the data into database.
You need to make the changes in database schema. Add one more column(is_validated), to specify whether the data is validated or not for the user(As mentioned by you, you are firstly logging in user in your application).
When you are fetching data again, you can show the form according to is_validated flag.
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
....
}
})
I'm using Google Analytics with goal tracking to track when a user submits a form that is on every page of my website. Currently this tells me when the form has been submitted, but is there a way of passing through the page name as well so I can track what page the form has been sent from?
My goal tracking is set up with the Event goal type and I have configured the goal to use a category, action and label with the following code on the submit button, which works fine:
onclick="_gaq.push(['_trackEvent', 'Total Form Submits', 'Submit', 'Form Submit']);"
If you set the second dimension in the events report to "page" it will show you the path were the event was triggered. For goals you can see the info in the conversions->goal urls report. So you can see where your goal was triggered without additional code.
You could also replace your event action or label with a "form name" that would allow you to identify your form. No point in sending in "submit" and "form submit".
An example, for a contact us form:
onclick="_gaq.push(['_trackEvent', 'Total Form Submits', 'Contact Us', 'Submit']);"
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.