Jetzt Mitglied werden
Kostenlos registrieren und die vielen Vorteile der Webmasterpro-Mitgliedschaft nutzen.
Forum - Entwicklung
- Markup (HTML, XML, etc.) und CSS
- Skriptsprachen (PHP, Javascript, etc.)
- Datenbanken (SQL)
- CMS und Frameworks
- Flash und ActionScript
Info: Der Stern signalisiert, dass neue Beiträge vorhanden sind.
Alle Foren - Übersicht
Portal aktuelle Themen
Design aktuelle Themen
Server aktuelle Themen
- Webhosting und Webspace
- Betriebssysteme (Windows, Linux, etc.)
- Serveradministration
- Überwachung, Sicherheit und Backups
Management aktuelle Themen
Über Webmasterpro.de
Das Portal wird betrieben und entwickelt durch die Team23 Agentur. Die Augsbuger Agentur hat sich auf Community Software und die Entwicklung von Webportalen spezialisiert.
Skriptsprachen (PHP, Javascript, etc.) - Forum
Derzeit sind Sie als Gast in unserem Forum aktiv. Für das Schreiben registrieren Sie sich bitte. Unser Forum ist eine Austauschplattform für Webworker zum Kommunizieren, Helfen, Informieren und Hilfe finden. Auf der rechten Seiten finden Sie eine Forenübersicht über alle Bereiche des Webmaster-Forums. Unterhalb finden Sie alle aktuellen Themen.
Diskutieren Sie hier über die serverseitige Skriptsprachen PHP und Python und über dynamische Webseitenerstellung mit Javascript und Ajax.
jQuery Calculation Rechner Problem... Javascript...
ich kenn mich nicht wirklich mit Javasript aus.... ich brauch für eine Website einen kleinen Rechner der einige Objekte mit Anzahl auswahl zusammen rechnet und die Summe jedes einzelnen und die Gesamtsumme aller Objekte ausgibt und dann noch die Gesamtsumme aller Objekte mit 2,45 Multipliziert.
Ich hab mir dazu jQuery Calculation Plug-in (jQuery Calculation Plug-in) Heruntergeladen und versucht mir den Rechner zu bauen, hat alles geklapt bis auf den letzten Punkt, dass ich nicht weiß wie ich in der Spalte grandTotal2 das Ergebnis aus grandTotal mit 2,45 Multiplizieren kann... ich hoffe das mir jemand helfen kann.
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jQuery Calculation Plug-in</title>
<!---// load jQuery v1.3.1 from the GoogleAPIs CDN //--->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<!--// load jQuery Plug-ins //-->
<script type="text/javascript" src="http://www.pengoworks.com/workshop/jquery/calculation/jquery.calculation.js"></script>
<script type="text/javascript">
var bIsFirebugReady = (!!window.console && !!window.console.log);
$(document).ready(
function (){
// update the plug-in version
$("#idPluginVersion").text($.Calculation.version);
/*
$.Calculation.setDefaults({
onParseError: function(){
this.css("backgroundColor", "#cc0000")
}
, onParseClear: function (){
this.css("backgroundColor", "");
}
});
*/
// bind the recalc function to the quantity fields
$("input[name^=qty_item_]").bind("keyup", recalc);
// run the calculation function now
recalc();
// automatically update the "#totalSum" field every time
// the values are changes via the keyup event
$("input[name^=sum]").sum("keyup", "#totalSum");
// automatically update the "#totalAvg" field every time
// the values are changes via the keyup event
$("input[name^=avg]").avg({
bind:"keyup"
, selector: "#totalAvg"
// if an invalid character is found, change the background color
, onParseError: function(){
this.css("backgroundColor", "#cc0000")
}
// if the error has been cleared, reset the bgcolor
, onParseClear: function (){
this.css("backgroundColor", "");
}
});
// automatically update the "#minNumber" field every time
// the values are changes via the keyup event
$("input[name^=min]").min("keyup", "#numberMin");
// automatically update the "#minNumber" field every time
// the values are changes via the keyup event
$("input[name^=max]").max("keyup", {
selector: "#numberMax"
, oncalc: function (value, options){
// you can use this to format the value
$(options.selector).val(value);
}
});
// this calculates the sum for some text nodes
$("#idTotalTextSum").click(
function (){
// get the sum of the elements
var sum = $(".textSum").sum();
// update the total
$("#totalTextSum").text("$" + sum.toString());
}
);
// this calculates the average for some text nodes
$("#idTotalTextAvg").click(
function (){
// get the average of the elements
var avg = $(".textAvg").avg();
// update the total
$("#totalTextAvg").text(avg.toString());
}
);
}
);
function recalc(){
$("[id^=total_item]").calc(
// the equation to use for the calculation
"qty * price",
// define the variables used in the equation, these can be a jQuery object
{
qty: $("input[name^=qty_item_]"),
price: $("[id^=price_item_]")
},
// define the formatting callback, the results of the calculation are passed to this function
function (s){
// return the number as a dollar amount
return s.toFixed(2) + "€";
},
// define the finish callback, this runs after the calculation has been complete
function ($this){
// sum the total of the $("[id^=total_item]") selector
var sum = $this.sum();
$("#grandTotal").text(
// round the results to 2 digits
sum.toFixed(2) + "€"
);
}
);
}
</script>
</head>
<body>
<table width="500">
<col style="width: 50px;" />
<col />
<col style="width: 60px;" />
<col style="width: 110px;" />
<tr>
<th width="15" align="left">
Anzahl
</th>
<th width="140" align="left">
Produkt
</th>
<th width="140" align="right">
Preis
</th>
<th width="180" align="right">
Preis Total
</th>
</tr>
<tr>
<td align="left">
<input type="text" name="qty_item_1" id="qty_item_1" value="0" size="2" />
</td>
<td>
<a>Stuhl</a>
</td>
<td align="right" id="price_item_1">
19.25 €
</td>
<td align="right" id="total_item_1">
19.25 €
</td>
</tr>
<tr>
<td align="left">
<input type="text" name="qty_item_2" id="qty_item_2" value="0" size="2" />
</td>
<td>
<a>Sofa</a>
</td>
<td align="right" id="price_item_2">
1400.00 €
</td>
<td align="right" id="total_item_2">
1400.00 €
</td>
</tr>
<tr>
<td align="left">
<input type="text" name="qty_item_3" id="qty_item_3" value="0" size="2" />
</td>
<td>
<a>Schrank</a>
</td>
<td align="right" id="price_item_3">
200.25 €
</td>
<td align="right" id="total_item_3">
200.25 €
</td>
</tr>
<tr>
<td colspan="3" align="right">
<strong>Grand Total:</strong>
</td>
<td align="right" id="grandTotal">
</td>
</tr>
<tr>
<td colspan="3" align="right">
<strong>Grand Total2:</strong>
</td>
<td align="right" id="grandTotal2">
</td>
</tr>
</table>
</body>
</html>
|
etwa in ~ Zeile 120:
1 2 3 4 | $("#grandTotal").text(
// round the results to 2 digits
sum.toFixed(2) + "€"
);
|
füge nachher folgendes hinzu:
1
2
3
4
5 | var sum2 = sum*2.45;
$("#grandTotal2").text(
// round the results to 2 digits
sum2.toFixed(2) + "€"
);
|
das sollte dein gewünschtes Ergebnis bringen...

