Weired Behaviour of FIREFOX with Decimals. :) Or I am screwing something. ;)

Discussion in 'JavaScript' started by xprienced, Oct 27, 2007.

  1. #1
    FOllowing script works in IE and shows Decimal Points .... BUT FIREFOX just ignores the Decimal Points. ANY CLUES?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script language="javascript1.2">
    function calcu()
    {
    var value1=0.00;


    value1 = (document.form1.r1.value * document.form1.q1.value)




    myvar =(parseFloat(value1))
    document.form1.subt.value=myvar
    alert(myvar)
    }
    </script>
    </head>

    <body>


    <p><b><form id="form1" name="form1" method="post" action="">

    QTY
    <select name="q1">
    <option value="0" selected="selected">0</option>
    <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>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    </select>
    <b>
    Rate
    <input type="text" name="r1" value="78.99" />
    </b> </p>

    <p><br />
    <br />
    Sub Total
    <input type="text" name="subt" size="7" maxlength="3" class="formbrdr" />
    </p>
    <p>
    <input type="button" name="Button" value="Calc" onclick="calcu()" />
    </p></form>
    </body>
    </html>
     
    xprienced, Oct 27, 2007 IP
  2. xprienced

    xprienced Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    :mad:

    ;) ;) ;)


    Culprit is maxlength="3"

    And I was blaming Fire Fox ......
     
    xprienced, Oct 27, 2007 IP
  3. gota

    gota Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You have the attribute maxlength set to 3, FireFox uses that value even if the value is dynamically set after the page loads. Internet Explorer ignores maxLength, for many versions of that browser. When it does work, you need to use camelCase because the attribute name is case sensitive in dumb IE!
     
    gota, Oct 27, 2007 IP