Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Dec 16, 2011 @ 19:01
    Bjarne Fyrstenborg
    0

    Quantities of a product

    Hi guys

    I just want to let you know what I did to prevent the error when deleting the quantity and click on "add to cart", so the user not get the error: the input string was not in correct format: http://starterkit.teacommerce.dk/en/products/category-a.aspx

    I have changed this in product_product.xslt:

    <input type="text" name="quantity" id="quantity" class="quantity" value="1" />
    

    to:

    <input type="text" name="quantity" id="quantity" class="quantity" value="1" onblur="if (this.value == '') {{ this.value = '1'; }}" onfocus="if (this.value == '1') {{ this.value = '1'; }}" />
    

    and the same in productList_product.xslt just without id="qunatity"..
    then if the user tries to remove the quantity, it just use 1 as standard quantity and you will not get the error message..

    just a quick fix on the problem :)

    Bjarne

  • Anders Burla 2560 posts 8256 karma points
    Dec 21, 2011 @ 17:23
    Anders Burla
    0

    Hi Bjarne

    Great info - just to further exhance your code - I think that the onfocus method doesnt do anything. If value = 1 then set value = 1 :)

    Kind regards
    Anders

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Dec 21, 2011 @ 17:54
    Bjarne Fyrstenborg
    0

    Hi Anders

    Yes, it just set the value to 1 when the value is 1, but it isn't something the eye will notice.. I'm not sure if the browser will do any changes or it doesn't do anything when the value is 1.

    or you could set it to an empty string on click: onfocus="if (this.value == '1') {{ this.value = ' '; }}" .. but that only works when the value is 1.. so I think you'll have to make a variable with the current value, and use that instead of 1. So it also works with 2, 3, 4 and so on..
    But in my case I just want to keep the number in the textbox :) 

    Bjarne

Please Sign in or register to post replies

Write your reply to:

Draft