php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger

PHP Einsteiger PHP Problemlösungen für Spracheinsteiger
Archive: 2004, 2004/2, 2005, 2005/2, 2006, 2007, 2008, 2009, 2010,

Antwort
 
LinkBack Themen-Optionen Thema bewerten
Alt 17.01.2012, 15:52  
Neuer Benutzer
 
Registriert seit: 17.01.2012
Beiträge: 3
PHP-Kenntnisse:
Anfänger
iDodder befindet sich auf einem aufstrebenden Ast
Standard id Problem PHP, jQuery Rechner Formular...

Hallo, ich habe einen Rechner mit jQuery calculation erstellt und möchte das Formular als e-mail versenden. Nun weiß ich nicht wie man z.B. die id="grandTotal" oder die id="total_item_1" in PHP auslesen kann…. wie man das z.B. mit den name="qty_item_1" macht weiß ich ja aber wie geht das bei id=""…? kann mir bitte jemand Helfen?

kleiner Beispielrechner

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  -------TOTAL PREISE --------
			"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 -------- DA * "2" ------- SUMME MAL 2 --------
				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>

</head>
<body>



<div id="seitenbereich">


<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">
    <input class ="send_button" type="submit" 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&sup3;
    </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&sup3;
    </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&sup3;
    </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&sup3;
    </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&sup3;
    </td>
</table>
</div>
iDodder ist offline   Mit Zitat antworten
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 17.01.2012, 15:59  
Erfahrener Benutzer
 
Registriert seit: 22.01.2005
Beiträge: 606
Connar befindet sich auf einem aufstrebenden Ast
Standard

Gar nicht.

Du müsstest die Daten in irgendeiner Form verpacken und an das Script schicken. Also entweder, indem du sie als Parameter an die URL anhängst (index.php?param1=value1&param2=value2) oder indem du sie per POST schickst. Also automatisch ein Formular zusammen bauen lässt mit den entsprechenden Feldern und das abschickst. Ist mit jQuery auch kein großes Problem, da du dort ja auf alle Felder zugreifen kannst und diese in das Formular überträgst.

Code:
<td id="grandTotal"></td>
...
<form id="inputForm" method="post" action="index.php">
<input type="hidden" id="inputGrandTotal" name="grandTotal" />
</form>
<script type="text/javascript>
function sendData() {
    $("#inputGrandTotal").val($("#gradTotal"));
    $("#inputForm").submit();
}
</script>

MFG Connar
Connar ist offline   Mit Zitat antworten
Alt 18.01.2012, 04:38  
Neuer Benutzer
 
Registriert seit: 17.01.2012
Beiträge: 3
PHP-Kenntnisse:
Anfänger
iDodder befindet sich auf einem aufstrebenden Ast
Standard Danke, aber es kommt leider nur [object Object] an…

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&sup3;
    </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&sup3;
    </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&sup3;
    </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&sup3;
    </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&sup3;
    </td>
</table>

</div>
</form>
</form>
</body>
</html>
iDodder ist offline   Mit Zitat antworten
Alt 18.01.2012, 09:05  
Erfahrener Benutzer
 
Registriert seit: 22.01.2005
Beiträge: 606
Connar befindet sich auf einem aufstrebenden Ast
Standard

Oh, entschuldigung. Das müsste natürlich

Code:
$("#inputgrandTotal").val($("#grandTotal").text());
heißen. Wenn der Button mit im Formular ist, brauchst du übrigens das

Code:
$("#inputForm").submit();
nicht mehr, aber da kannst du dir ja überlegen, wie du es am besten machen willst. Du könntest nämlich z.B. ein eigenes Formular (<form>...</form>) nur für die hidden-input-fields machen, damit die Daten deiner Checkboxes, etc. nicht mit übertragen werden.


MFG Connar
Connar ist offline   Mit Zitat antworten
Alt 19.01.2012, 16:57  
Neuer Benutzer
 
Registriert seit: 17.01.2012
Beiträge: 3
PHP-Kenntnisse:
Anfänger
iDodder befindet sich auf einem aufstrebenden Ast
Standard Danke... aber...

Danke Connar, du hast mir sehr geholfen!

ich hab das ganze jetzt so gemacht...

Code:
<script type="text/javascript">
function sendData() {
        $("#inputgrandTotal").val($("#grandTotal").text());
	$("#inputgrandTotal2").val($("#grandTotal2").text());
	$("#inputtotal_item_1").val($("#total_item_1").text());
	$("#inputtotal_item_2").val($("#total_item_2").text());
	$("#inputtotal_item_3").val($("#total_item_3").text());
	$("#inputtotal_item_4").val($("#total_item_4").text());
	$("#inputtotal_item_5").val($("#total_item_5").text());
	}
</script>



und...

Code:
<form id="inputForm" method="post" action="formularauswertung.php">
<input type="hidden" id="inputgrandTotal" name="grandTotal" />
<input type="hidden" id="inputgrandTotal2" name="grandTotal2" />
<input type="hidden" id="inputtotal_item_1" name="total_item_1" />
<input type="hidden" id="inputtotal_item_2" name="total_item_2" />
<input type="hidden" id="inputtotal_item_3" name="total_item_3" />
<input type="hidden" id="inputtotal_item_4" name="total_item_4" />
<input type="hidden" id="inputtotal_item_5" name="total_item_5" />
</form>



PHP...

PHP-Code:
<?php
echo $_POST['qty_item_1'] ." "$_POST['produkt1'] ." "$_POST['checkbox1'] ." "$_POST['checkbox2'] ." "$_POST['total_item_1'] . "<br>";
echo 
$_POST['qty_item_2'] ." "$_POST['produkt2'] ." "$_POST['checkbox3'] ." "$_POST['checkbox4'] ." "$_POST['total_item_2'] . "<br>";
echo 
$_POST['qty_item_3'] ." "$_POST['produkt3'] ." "$_POST['checkbox5'] ." "$_POST['checkbox6'] ." "$_POST['total_item_3'] . "<br>";
echo 
$_POST['qty_item_4'] ." "$_POST['produkt4'] ." "$_POST['checkbox7'] ." "$_POST['checkbox8'] ." "$_POST['total_item_4'] . "<br>";
echo 
$_POST['qty_item_5'] ." "$_POST['produkt5'] ." "$_POST['checkbox9'] ." "$_POST['checkbox10'] ." "$_POST['total_item_5'] . "<br>";
echo 
"grandTotal:" ." "$_POST['grandTotal'] . "<br>";
echo 
"grandTotal2:" ." "$_POST['grandTotal2'] . "<br>";
?>


der neue gesamtcode...

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").text());
	$("#inputgrandTotal2").val($("#grandTotal2").text());
	$("#inputtotal_item_1").val($("#total_item_1").text());
	$("#inputtotal_item_2").val($("#total_item_2").text());
	$("#inputtotal_item_3").val($("#total_item_3").text());
	$("#inputtotal_item_4").val($("#total_item_4").text());
	$("#inputtotal_item_5").val($("#total_item_5").text());
	}
</script>
</head>

<body>

<form id="inputForm" method="post" action="formularauswertung.php">
<input type="hidden" id="inputgrandTotal" name="grandTotal" />
<input type="hidden" id="inputgrandTotal2" name="grandTotal2" />
<input type="hidden" id="inputtotal_item_1" name="total_item_1" />
<input type="hidden" id="inputtotal_item_2" name="total_item_2" />
<input type="hidden" id="inputtotal_item_3" name="total_item_3" />
<input type="hidden" id="inputtotal_item_4" name="total_item_4" />
<input type="hidden" id="inputtotal_item_5" name="total_item_5" />

<div id="seitenbereich">

<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>
        <input type="hidden" name="produkt1" value="Produkt1">Produkt 1
    </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&sup3;
    </td>
</tr>
<tr>
    <td align="left">
        <input type="text" name="qty_item_2" id="qty_item_2" value="" size="2" />
    </td>
    <td>
    	<input type="hidden" name="produkt2" value="Produkt2">Produkt 2
    </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&sup3;
    </td>
</tr>
<tr>
    <td align="left">
        <input type="text" name="qty_item_3" id="qty_item_3" value="" size="2" />
    </td>
    <td>
    	<input type="hidden" name="produkt3" value="Produkt3">Produkt 3
    </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&sup3;
    </td>
</tr>
<tr>
    <td align="left">
        <input type="text" name="qty_item_4" id="qty_item_4" value="" size="2" />
    </td>
    <td>
    	<input type="hidden" name="produkt4" value="Produkt4">Produkt 4
    </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_4">
        <p class="hide">0.20</p>
    </td>
    <td align="right" id="total_item_4">
        0.20 m&sup3;
    </td>
</tr>
<tr>
<tr>
    <td align="left">
        <input type="text" name="qty_item_5" id="qty_item_5" value="" size="2" />
    </td>
    <td>
    <input type="hidden" name="produkt5" value="Produkt5">Produkt 5
    </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_5">
        <p class="hide">0.80</p>
    </td>
    <td align="right" id="total_item_5">
        0.80 m&sup3;
    </td>
</table>

</div>
</form>
</form>
</body>
</html>


... Danke!

Aber hast du vielleicht noch eine Idee wie man die nicht ausgefüllten Felder nicht mit überträgt ... wenn man zb. nur 3 von 20 Felder ausfüllt, sollen nicht alle 20 übertragen werden sondern nur die 3 ausgefüllten.




.
iDodder ist offline   Mit Zitat antworten
Alt 19.01.2012, 17:23  
moderatives Dielektrikum
 
Benutzerbild von nikosch
 
Registriert seit: 21.05.2008
Beiträge: 35.987
PHP-Kenntnisse:
Fortgeschritten
nikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunftnikosch hat eine strahlende Zukunft
Standard

Zitat:
<input type="hidden" id="inputtotal_item_1" name="total_item_1" />
<input type="hidden" id="inputtotal_item_2" name="total_item_2" />
Grusel. Schon mal was von Arrays gehört?
Zitat:
$("#inputtotal_item_1").val($("#total_item_1").tex t());
$("#inputtotal_item_2").val($("#total_item_2").tex t());
Graus. Oder von Funktionen?
__________________
--
One pixel is still too big. Please make it smaller. ASAP.

Initiative Mittelstand.
Die wichtigste Gestaltungsregel im Screendesign ist Pi mal Daumen des Arbeitgebers.
--
nikosch ist offline   Mit Zitat antworten
Antwort


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
jQuery Slider Problem atkaz JavaScript, Ajax und mehr 1 16.11.2011 22:19
[Erledigt] Dynamisches Formular - Problem mit Leerzeichen Blinddog PHP Einsteiger 5 09.09.2011 09:41
[Erledigt] Formular Problem nicht zwingende Checkboxen dynamischer Sammel DB-Eintrag supervision PHP Einsteiger 4 28.07.2011 08:07
Problem mit jQuery add/remove Class kidding JavaScript, Ajax und mehr 2 04.05.2011 19:12
Problem mit Feldüberprüfung bei Email Formular onaflower PHP Einsteiger 11 16.03.2011 22:41
Problem mit Pflichtfeldern in einem Formular Ötzi PHP Einsteiger 13 24.01.2011 17:01
jQuery Ajax und $(this) Problem halskrause JavaScript, Ajax und mehr 8 01.03.2010 17:39
[Erledigt] PHP Formular =&gt; Problem =&gt; Email kommt nicht an... benschiaa PHP Tipps 2009 21 25.03.2009 11:54
Assoziatives Array und ctype_digit Problem im Formular. Radik PHP Tipps 2009 6 16.02.2009 21:58
[Erledigt] Formular Problem (Datenbank Abfrage) halekin PHP Tipps 2009 2 14.01.2009 12:45
Problem mit Formular, Daten an datenbank senden Aurec PHP Tipps 2008 11 20.11.2008 18:17
Problem mit IF und Formular Black-Devil PHP Tipps 2008 12 03.03.2008 17:54
Problem mit interaktiven Formular max-dhom HTML, Usability und Barrierefreiheit 0 19.09.2006 10:28
[Erledigt] Problem mit dem Füllen einer Tabelle über Formular PHP Tipps 2006 18 10.01.2006 12:51
Problem mit Formular + Antwortseite PHP Tipps 2004 2 22.07.2004 09:51

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
$.calculation.setdefaults, jquery rechner, qty_item_1 jquery, jquery rechner mit hidden field, jquery rechnen, jquery input feld füllen, formulare mit jquery und php rechnen, formular berechnung php ajax, jquery formulardaten brechnen, html jquery rechner, php script calculator, mit tabellenwerten rechnen jquery, jquerry formular rechnen, checkbox rechner jquery, jquery formular rechnen deutsch, jquery form calculations, php jquery formular zur berechnung von input, php eingabefeld ausrechnen jquery, jquery formular rechnen, jquery kalkulator

Alle Zeitangaben in WEZ +2. Es ist jetzt 18:55 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum