SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why does this code work in Mozilla and not in IE???

    Hi, I'm new here. Recommended by my tutor.

    I am writing a pay online form and the code to calculate the amount for passing to the payment gateway works fine in Mozilla. Not in IE! Help!!!!
    In IE it just sets the value to 0 as if it's not recognising the value of the drop-down menu choice (which I need to calculate the amount payable).
    My code validates, but doesn't work. Thanks for reading.

    <script type="text/javascript">

    function calculate() {
    menuchoice = document.nochexform.menuchoice.value
    var A =0;
    var B =0;
    var C=0;

    switch(menuchoice) {

    case '1':
    A = 4.55;
    B = document.nochexform.numpeople1.value;
    C = (A * B);
    document.nochexform.amount.value = C;
    break;
    case '2':
    A = 5.55;
    B = document.nochexform.numpeople1.value;
    C = (A * B);
    document.nochexform.amount.value = C;
    break;
    case '3':
    A = 6.55;
    B = document.nochexform.numpeople1.value;
    C = (A * B);
    document.nochexform.amount.value = C;
    break;
    case '4':
    A = 7.55;
    B = document.nochexform.numpeople1.value;
    C = (A * B);
    document.nochexform.amount.value = C;
    break;

    case '5':
    A = 8.55;
    B = document.nochexform.numpeople1.value;
    C = (A * B);
    document.nochexform.amount.value = C;
    break;

    default:
    document.nochexform.amount.value = 0;

    }
    }
    </script>

    </head>

    ~~~~~~~~~~~~~~~~~~~~~~
    My form has the following text boxes:

    Menu Number: <select name="menuchoice" onblur="calculate()">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    </select> for <input type="text" name="numpeople1" size ="3" onkeypress="return onlyDigits(event,'decOK')" onblur="calculate()"/> people <b>(minimum 10) </b><br/>

    <br/>Your order total is: <br/>
    &pound;<input type="text" name="amount" size="8" onblur="calculate()"/><br/>
    <br/>

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spot_on
    <select name="menuchoice" onblur="calculate()">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    </select>
    If you want to read the value of a select, consider adding some values to its options.

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry Logic Ali, I don't know what you mean. Can you expand please?

    spot_on

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    He means

    Originally Posted by spot_on
    <select name="menuchoice" onblur="calculate()">
    <option value = "1">1</option>
    <option value = "2">2</option>
    <option value = "3">3</option>
    <option value = "4">4</option>
    <option value = "5"> 5</option>
    </select>

    Oh!
    Be sure you are validating the amounts and what not on the server end of things, Javascript is pretty easy to hack
    Good luck
    AFrieze

  5. #5
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Logic Ali and AFrieze! That all works fine now. Why didn't I think if that?!!

    So, does the code look for different things than what is displayed? I mean, I referred to the .value bit, and Mozilla Firefox coped, all correct 1st time. Does IE do things differently?

    Thank again guys, saved me hours.

    Spot_on

  6. #6
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the only thing you really need to know is that IE is not very godd, its old and doesnt support little things that it should. When programming in IE its less forgiving that using something like firefox, you need to make sure that code is complete and shortcuts cant be taken
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"


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
  •