diehard Posted November 23, 2012 Share Posted November 23, 2012 (edited) <p>Hi people, I have a little problem with this script. The script works perfect on all other browsers, but not with Internet Explorer (all versions). The standard value of the totals is 0 and when using IE it keeps standing on 0. It won't change when selecting another option. With other browsers, like Opera, Firefox and Chrome, it calculates and works fine. Anyone an idea what the problem is? I can't find the solution. Edited November 23, 2012 by trq Quote Link to comment https://forums.phpfreaks.com/topic/271069-script-calculates-in-other-browsers-but-not-with-ie-versions/ Share on other sites More sharing options...
diehard Posted November 23, 2012 Author Share Posted November 23, 2012 (edited) It doesnt fit inside the topic. Here the total script. <form method="post"> <table> <tr> <td> <select name="select1" id="select1"> <?php $query = mysql_query("SELECT `product`, `price`, `setup`, `id` FROM `database_select1` WHERE `type` = 'select1' ORDER BY `id` ASC"); while($row = mysql_fetch_object($query)){ { $id = $row->id; $setup = number_format($row->setup, 2, ',', '.'); $price = number_format($row->price, 2, ',', '.'); } echo "<option value=\"$id\">$row->product $setup </option>"; } mysql_free_result($query); ?> </select> </td> </tr> <tr> <td> <select name="select2" id="select2"> <?php $query = mysql_query("SELECT `product`, `price`, `id` FROM `database_select2` WHERE `type` = 'select2' ORDER BY `id` ASC"); while($row = mysql_fetch_object($query)){ { $id = $row->id; $price = number_format($row->price, 2, ',', '.'); // if($_GET['select2'] == $row->product){ echo "<option value=\"$id\" selected=\"selected\">$row->product -> $price </option>"; } else{ } echo "<option value=\"$id\">$row->product -> $price </option>"; } } mysql_free_result($query); ?> </select> </td> </tr> <tr> <td> <select name="term" id="term"> <option value="1">1 Month</option> <option value="3">3 Months</option> <option value="6">6 Months</option> </select> </td> </tr> <tr> <td>Total costs:</td> <td><input type="text" name="totalcost" id="totalcost" value="0"/></td> </tr> <tr> <td>Total setup:</td> <td><input type="text" name="totalsetup" id="totalsetup" value="0/></td> </tr> </table> </form> <!--START PHP VAR1 - Defining selectbox variables (crossmatch value-price): line 153 - 225--> <?php #Defining "costs" variable $costsarray = ''; $query = mysql_query("SELECT `price`, `id` FROM ` database_select1` ORDER BY `id` ASC"); while($row = mysql_fetch_array($query)){ $id = $row['id']; $price = $row['price']; $costsarray.= "$id : $price, "; } $costsarray = trim($costsarray, ', '); mysql_free_result($query); #Defining "setup" variable $setuparray = ''; $query = mysql_query("SELECT `setup`, `id` FROM `database_select2` WHERE `setup` > 0 ORDER BY `id` ASC"); while($row = mysql_fetch_array($query)){ $id = $row['id']; $setup = $row['setup']; $setuparray .="$id : $setup, "; } $setuparray = trim($setuparray, ', '); mysql_free_result($query); ?> <!--END PHP VAR1 START automatic recalculation (Javascript + jQuery)--> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> //START Javascript F1 - Function to format raw output to EUR function formatDollar(num) { var p = num.toFixed(2).split("."); return p[0].split("").reverse().reduce(function(acc, num, i, orig) { return num + (i && !(i % 3) ? "." : "") + acc; }, "") + "," + p[1]; } //END Javascript F1 //START Javascript VAR2 - Defining variables and filling arrays (function($) { //standard costs var costs = {<?php echo $costsarray; ?>} //setup costs var setup = {<?php echo $setuparray; ?>} //END VAR 2 //START onchange activity declaration for selectbox $("#select1").change(function(){calc_and_show_total();}) $("#select2").change(function(){calc_and_show_total();}) $("#term").change(function(){calc_and_show_total();}) //END onchange declaration //START Javascript F2 - Calculating all selected variables function calc_and_show_total() { //monthly costs var term = $("#term").val(); var select1 = costs[$("#select1").val()]; var select2 = costs[$("#select2").val()]; var costssum = (select1+select2)*term //setup costs var sselect1 = setup[$("#select1").val()]; var setupsum = sselect1 } //Format currency (Function F1) var coststotal = formatDollar(costssum); var setuptotal = formatDollar(setupsum); //Print to input field "total" $("#totalcost").val(coststotal); $("#totalsetup").val(setuptotal); } //end print //initialize our total calc_and_show_total(); })(this.jQuery); </script> Edited November 23, 2012 by diehard Quote Link to comment https://forums.phpfreaks.com/topic/271069-script-calculates-in-other-browsers-but-not-with-ie-versions/#findComment-1394601 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.