Script rekent uit in alle browsers, behalve IE

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ventilatiesysteem Productontwikkelaar HBO WO Verwa

Samengevat: Zij bieden flexibele ventilatiematerialen, geluidsdempers, rookgasafvoer producten en industrieslangen. Ben jij een technisch productontwikkelaar? Heb jij ervaring met het ontwikkelen van nieuwe producten? Vaste baan: Technisch Productontwikkelaar HBO WO €3.000 - €4.000 Zij bieden een variëteit aan flexibele ventilatiematerialen, geluiddempers, rookgasafvoer producten, industrieslangen en ventilatieslangen voor de scheepsbouw. Met slimme en innovatieve materialen zorgen wij voor een gezonde en frisse leefomgeving. Deze werkgever is een organisatie die volop in ontwikkeling is met hardwerkende collega's. Dit geeft goede ontwikkelingsmogelijkheden. De branche van dit bedrijf is Techniek en Engineering. Functie: Voor de vacature als Technisch Productontwikkelaar Ede Gld HBO WO ga

Bekijk vacature »

Die hard

die hard

22/11/2012 16:26:02
Quote Anchor link
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?

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<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>
Gewijzigd op 22/11/2012 17:11:55 door Die hard
 
PHP hulp

PHP hulp

18/05/2024 14:55:22
 
- SanThe -

- SanThe -

22/11/2012 16:32:56
Quote Anchor link
Heb jij een spatie in de GET-naam?
if($_GET[' select2'] == $row->product){

Of moet het gewoon dit zijn?
if($_GET['select2'] == $row->product){
 
Die hard

die hard

22/11/2012 16:54:57
Quote Anchor link
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.
 
- SanThe -

- SanThe -

22/11/2012 17:04:28
Quote Anchor link
Die hard op 22/11/2012 16:54:57:
Ik heb het nu in de post aangepast.


Is nog hetzelfde.
 
Die hard

die hard

22/11/2012 17:17:24
Quote Anchor link
- SanThe - op 22/11/2012 17:04:28:
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
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.