SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    click the button then pop up a dialogthen submit the button

    Code:
    <button onclick="productAddToCartForm.submit(this)" class="button btn-cart" title="Add to Cart" type="button"><span><span>Add to Cart</span></span></button>
    the original js code:


    Code:
    var productAddToCartForm = new VarienForm('product_addtocart_form');
                productAddToCartForm.submit = function(){
                        if (this.validator.validate()) {
                                this.form.submit();
                        }
                }.bind(productAddToCartForm);

    The above is the normal step. which is click the button, then submit the form. now, i want to add one step before the form is submitted. the step is. when click the button, it will pop up a dialog. there are some content on it. when close the dialog. then submit the form.

    1, first i think i shoulf use jquery in
    Code:
    productAddToCartForm.submit = function(){....}
    .if the page have loaded the jquery library.but i don't know how to add jquery code in the function. thank you


    pop up dialog effect

    popup.gif

  2. #2
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    my test code, but it doesn't work.

    Code:
    <div id="popup" style="display:none">
       <p>test</p>
        <a href="#" >test</a> 
        
    </div>
    js code:

    Code:
    productAddToCartForm.submit = function(){
                            if (this.validator.validate()) {
                           $("#popup").show('slow', function() {
                           $('#popup').hide(1000,'slow', function() {
                          this.form.submit();
                           });
                           });
                          }       
                        }
                    }.bind(productAddToCartForm);
    when i click the button, there is now show of the dialog. thank you

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by runeveryday View Post
    when i click the button, there is now show of the dialog. thank you
    When I see this comment, I think that things are working for you.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •