Script rekent uit in alle browsers, behalve IE
Bij de andere browsers rekent het script gewoon alles prima uit.
Iemand een idee wat het kan zijn?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<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>
<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>
Gewijzigd op 22/11/2012 17:11:55 door Die hard
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:
Is nog hetzelfde.
Die hard op 22/11/2012 16:54:57:
Ik heb het nu in de post aangepast.
Is nog hetzelfde.
I see. 1e post aangepast!
Gewijzigd op 22/11/2012 23:05:17 door die hard