Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 7 of 7

Thread: Javascript doesn't work in IE

  1. #1
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Question Javascript doesn't work in IE

    We updated our one page checkout to automatically select the card type based on the card number.

    However this did not work in IE and it would not update the card type (thus very annoyed customers)

    can anyone help me to get this to work in IE as well as the other browsers?
    Code:
    function CardTypeSelector(num) {
        var re = /^4/;
        if (re.test(num)) {
            $('#CardType').prepend('<option value="Visa" selected=selected>Visa</option>');
        }
        re = /^5[1-5]/;
        if (re.test(num)) {
            $('#CardType').prepend('<option value="MasterCard" selected=selected>MasterCard</option>');
        }
        re = /^(4026|417500|4508|4844|4913|4917)/;
        if (re.test(num)) {
            $('#CardType').prepend('<option value="VisaElectron" selected=selected>VisaElectron</option>');
        }
    };
    This works perfectly in chrome but sadly the bulk of customers are still on IE.

    thanks in advance.
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience

  2. #2
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    Hi

    I don't think you need to worry about prepending additional html into the select. Try changing your function to this:

    Code:
    function CardTypeSelector(num) {
        var re = /^4/;
        if (re.test(num)) {
            $('#CardType').val('Visa');
        }
        re = /^5[1-5]/;
        if (re.test(num)) {
            $('#CardType').val('MasterCard');
        }
        re = /^(4026|417500|4508|4844|4913|4917)/;
        if (re.test(num)) {
            $('#CardType').val('VisaElectron');
        }
    };
    Adam

  3. #3
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    Does that set that value to the selected value of the drop down box.

    The idea is we will completely hide the drop down just to save the confused customers.

    Cheers Adam.
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience

  4. #4
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    Yep, that's right.... and if the select box is hidden, it *should* still work.

  5. #5
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    Perfect, I'll do some testing on that later today and come back to you.

    Cheers again.
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience

  6. #6
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    Isn't this a risky strategy? With credit card starting numbers possibly changing see http://en.wikipedia.org/wiki/Bank_card_number (not that I would take WIKI or any other online document as gospel).
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  7. #7
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    We only accept 3 major card (2 really)
    Visa and MasterCard.

    Had a look at that wiki when I was building the regex check to see what card it is.
    Really it comes down to if it starts with a 4 its a Visa, starts with a 5 its MasterCard.

    But I do see the issues with doing this.

    Problem is I had a customer ring up and do the order over the phone as he believed we could not accept a Visa debit card (only credit card), when we can, it is classed as a Visa.
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience