Community Forums 

Main Content

maximum qty and add to cart w/o leaving page & refresh

    Jun 02 2011 15:42:37

    #1

    JoanB

    Join date : 2011-05-27      Posts : 14

    I added this code to have the customer add items to the cart w/o leaving the page and having the page refreshed

    <input src="images/addtocart.gif" alt="add to cart" value="Add" type="image" onclick="alert('Order has been added to your cart\n\nThis page will refresh');">

    I added this code maximize qty allowed:

    <form name="celestial mirror" action="http://ww7.aitsafe.com/cf/add.cfm"; method="post" onsubmit="if(this.qty.value>1){alert('Maximum of 1 please');this.qty.value=2;return false;}">


    However, when I try to put these 2 things together, the result is:
    it adds whatever qty the customer puts in and refreshes the page and then it says what the maximum qty is even though the qty the customer put in has already been added

    Hope someone will understand what I'm saying here. Thanks a lot.



    Jun 02 2011 17:56:38

    #2

    Geoff

    Join date : 2008-09-18      Posts : 415

    Remove the onclick attribute from the submit (image) input, and add it to the form onsubmit attribute like this -

    onsubmit="if(this.qty.value>1){alert('Maximum of 1 please');this.qty.value=1;return false;}else{alert('Order has been added to your cart\n\nThis page will refresh');}"



    Jun 02 2011 19:23:00

    #3

    JoanB

    Join date : 2011-05-27      Posts : 14

    Joined the forum today and asked my first question and what a quick response and accurate info. Didn't even realize there was malsforms to help. Came cross them by accident.

    THANK YOU