Guten Morgen Connar, Danke für deine schnelle Antwort! bei mir kommt da leider nur [object Object] an… es wäre super wenn du mir helfen könntest!
das hab ich nun in den head Bereich geschrieben…
Code:
<script type="text/javascript">
function sendData() {
$("#inputgrandTotal").val($("#grandTotal"));
$("#inputForm").submit();
}
</script>
und das hab ich nun im den body Bereich geschrieben…
Code:
<form id="inputForm" method="post" action="formularauswertung.php">
<input type="hidden" id="inputgrandTotal" name="grandTotal" />
und der Button…
Code:
<input class ="send_button" type="submit" onClick="sendData()" name="send_button" value="Absenden">
und das PHP (formularauswertung.php) für das kleine Beispiel...
PHP-Code:
<?php
echo "Produkt1:";
echo $_POST['qty_item_1'];
echo "Produkt2:";
echo $_POST['qty_item_2'];
echo "Produkt3:";
echo $_POST['qty_item_3'];
echo "Produkt4:";
echo $_POST['qty_item_4'];
echo "Produkt5:";
echo $_POST['qty_item_5'];
echo "Summe:";
echo $_POST['grandTotal'];
?>
hier der gesamte Code...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test</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) + "m³";
},
// 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) + "m³"
);
sum *= 2.45;
$("#grandTotal2").text(
// round the results to 2 digits
sum.toFixed(2) + "€"
);
}
);
}
function Bestaetigung () {
var x = window.confirm("Dieses Formular geht an " + document.Testform.action);
return x;
}
</script>
<script type="text/javascript">
function sendData() {
$("#inputgrandTotal").val($("#grandTotal"));
$("#inputForm").submit();
}
</script>
</head>
<body>
<div id="seitenbereich">
<form id="inputForm" method="post" action="formularauswertung.php">
<input type="hidden" id="inputgrandTotal" name="grandTotal" />
<div id="bereich_summe">
<table width="400">
</tr>
<td colspan="4" align="right">
</td>
<td align="right" id="grandTotal">
</td>
</tr>
<tr>
<td colspan="4" align="right">
</td>
<td align="right" id="grandTotal2">
</td>
</tr>
<tr>
<td colspan="5" align="right">
<br><input type="hidden" name="aktion" value="check">
<input class ="druck_button" type="button" name="druck_button" value="Drucken" onClick="window.print();">
</tr>
<tr>
<td colspan="5" align="right">
<form method="post" action=""/>
<input class ="send_button" type="submit" onClick="sendData()" name="send_button" value="Absenden">
</td>
</tr>
</table>
</div>
<br />
<div id="bereichrechner">
<div id="jason1">
<table width="800">
<col style="width: 50px;" />
<col />
<col style="width: 60px;" />
<col style="width: 110px;" />
<tr>
<th width="0">
</th>
<th width="180" align="left">
</th>
<th width="510" align="right">
</th>
<th width="50" align="right">
</th>
<th width="100" align="right">
</th>
</th>
</tr>
<tr>
<td align="left">
<input type="text" name="qty_item_1" id="qty_item_1" value="" size="2" />
</td>
<td>
<a>Produkt1</a>
</td>
<td align="left">
<input type="checkbox" name="checkbox1" class="option" value="checkbox1" /> checkbox1<input type="checkbox" name="checkbox2" class="option" value="checkbox2" />
checkbox2<br />
</td>
<td align="right" id="price_item_1">
<p class="hide">0.10</p>
</td>
<td align="right" id="total_item_1">
0.10 m³
</td>
</tr>
<tr>
<td align="left">
<input type="text" name="qty_item_2" id="qty_item_2" value="" size="2" />
</td>
<td>
<a>Produkt2</a>
</td>
<td align="left">
<input type="checkbox" name="checkbox3" class="option" value="checkbox3" /> checkbox3<input type="checkbox" name="checkbox4" class="option" value="checkbox4" />
checkbox4<br />
</td>
<td align="right" id="price_item_2">
<p class="hide">0.20</p>
</td>
<td align="right" id="total_item_2">
0.20 m³
</td>
</tr>
<tr>
<td align="left">
<input type="text" name="qty_item_3" id="qty_item_3" value="" size="2" />
</td>
<td>
<a>Produkt3</a>
</td>
<td align="left">
<input type="checkbox" name="checkbox5" class="option" value="checkbox5" /> checkbox5<input type="checkbox" name="checkbox6" class="option" value="checkbox6" />
checkbox6<br />
</td>
<td align="right" id="price_item_3">
<p class="hide">0.40</p>
</td>
<td align="right" id="total_item_3">
0.40 m³
</td>
</tr>
<tr>
<td align="left">
<input type="text" name="qty_item_4" id="qty_item_4" value="" size="2" />
</td>
<td>
<a>Produkt4</a>
</td>
<td align="left">
<input type="checkbox" name="checkbox7" class="option" value="checkbox7" /> checkbox7<input type="checkbox" name="checkbox8" class="option" value="checkbox8" />
checkbox8<br />
</td>
<td align="right" id="price_item_3">
<p class="hide">0.20</p>
</td>
<td align="right" id="total_item_3">
0.20 m³
</td>
</tr>
<tr>
<tr>
<td align="left">
<input type="text" name="qty_item_5" id="qty_item_5" value="" size="2" />
</td>
<td>
<a>Produkt5</a>
</td>
<td align="left">
<input type="checkbox" name="checkbox9" class="option" value="checkbox9" /> checkbox9<input type="checkbox" name="checkbox10" class="option" value="checkbox10" />
checkbox10<br />
</td>
<td align="right" id="price_item_1">
<p class="hide">0.80</p>
</td>
<td align="right" id="total_item_1">
0.80 m³
</td>
</table>
</div>
</form>
</form>
</body>
</html>