I am working on an ecommerce site for which, i want the add to cart button to open a lightbox with a form to accept some more details like quantity, etc. The problem is, the way
Just attach a click handler onto the button that submits the form, like so:
$("#id_of_submit_button").click(function(e) {
e.preventDefault();
e.stopPropagation();
});
That will keep the form from being submitted (or at least, it should). As for opening the lightbox, you should be able to just include that after the e.stopPropagation();
call above...just open it as normal.
The major problem you are probably going to have is how to include the information from the additional form in the lightbox with the original form. You may just want to submit all of it via a $.post
call, or perhaps do some $("form").append()
calls to insert hidden fields into the original form based on the information in the lightbox?