html5 - Javascript parseInt error on IE -


the below code doesn't work on ie, me?

onclick="x.value=parseint(b.value*d.value*c.value)+parseint(a.value) 

on other browsers, seems fine , doing calculation , giving output on ie no matter do, output stays 0 value, below whole form targeting issue better :

<form id="mainselection">         <h6>transfer fee calculator</h6>     <select name="a">     <option value="0">select</option>     <option value="0">dalaman</option>     <option value="30">bodrum</option> </select> <select name="b">     <option value="0">resort</option>     <option value="10">marmaris</option>     <option value="12">icmeler</option>     <option value="18">turunc</option> </select> <select name="c">     <option value="0">pax</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>   </select> <select name="d">     <option value="1">one way</option>     <option value="2">return</option> </select> <br /> <span class="total">total:</span><output name="x" for="a b c ">0</output>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="currency">£</span> <br /> <br /> <input type="button" value="calculate" class="cal-but" onclick="x.value=parseint(b.value*d.value*c.value)+parseint(a.value)"> <input type="button" value="book now" class="book" onclick="window.location='reservation.html'"> 

first thing not ie bug. it's using non-standard ways of accessing element names in javascript code.

the problem have you're using elements' name attribute global javascript variables. not (and never has been) recommended practice. browsers support backward-compatibility reasons, doesn't mean it'll continue working in future versions of browser. isn't standard , shouldn't used.

the correct way access individual elements directly in javascript using getelementsbyid() method. give cross-browser compatibility current code not have.

the solution:

  • step 1: add id='x' next name='x'. , same other elements you're accessing name

  • step 2: wherever you're using variables x names of elements, replace variable name document.getelementbyid('x').

    yes, it's lot more long-winded, correct way it.

that solve problem you.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -