Beste mensen ik heb een probleem met een script wat gewoon goed werkt op alle andere browsers, maar op alle versies van Internet Explorer niet. De standaard value is 0 en bij IE blijft die daar gewoon op staan en veranderd niet bij een andere selectie en past zich niet aan naar andere standaardwaardes.

Bij de andere browsers rekent het script gewoon alles prima uit.

Iemand een idee wat het kan zijn?


<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>
		<option value="12">12 Months</option>
		<option value="24">24 Months</option>
      	<option value="36">36 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>

Heb jij een spatie in de GET-naam?
if($_GET[' select2'] == $row->product){

Of moet het gewoon dit zijn?
if($_GET['select2'] == $row->product){
Dat is het probleem niet. Dat heb ik daarnet bij het posten per ongeluk gedaan. Ging wat fout tijdens het editten van de post. Ik heb het nu in de post aangepast.
Die hard op 22/11/2012 16:54:57

Ik heb het nu in de post aangepast.


Is nog hetzelfde.
- SanThe - op 22/11/2012 17:04:28

[quote="Die hard op 22/11/2012 16:54:57"]
Ik heb het nu in de post aangepast.


Is nog hetzelfde.
[/quote]

I see. 1e post aangepast!

Reageren