Jodarecode
10-22-2007, 05:35 PM
Ok, I need to do somthing simular to the php function below except for all the newly created textbox's. some kind of array grabing each value..
first line: "t1_1, t1_2"
newly created: "t2_1, t2_2"
newly created: "t3_1, t3_2"
newly created: "t4_1, t4_2"
newly created: "t5_1, t5_2"
newly created: "t6_1, t6_2"
....and so on
I dont want to have to create a line for who knows how many text boxes the customer creates and have to change each one, it would take to long.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Get values from new textbox values
</title>
<script type="text/javascript">
function viewsource() {
alert(document.body.innerHTML);
}
</script>
<script type="text/javascript">
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var frm=document.form0;
if (!frm.ary) frm.ary=[frm.t1_2];
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// numberd row
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// Item row
var cellRight1 = row.insertCell(1);
var el1 = document.createElement('input');
el1.type = 'text';
el1.name = 't' + iteration + '_1';
el1.id = 't' + iteration + '_1';
el1.size = 40;
cellRight1.appendChild(el1);
// Price row
var cellRight2 = row.insertCell(2);
var el2 = document.createElement('input');
frm.ary.push(el2);
el2.type = 'text';
el2.value = '';
el2.name = 't' + iteration + '_2';
el2.id = 't' + iteration + '_2';
el2.size = 5;
el2.onkeyup=Calc;
el2.onblur=Calc;
cellRight2.appendChild(el2);
}
</script>
<script type="text/javascript">
function Calc(){
var frm=document.form0;
if (!frm.ary) frm.ary=[frm.t1_2];
var total=0;
for (var zxc0=0;zxc0<frm.ary.length;zxc0++){
if (frm.ary[zxc0].value.length>0&&!isNaN(frm.ary[zxc0].value)) total+=frm.ary[zxc0].value*1;
}
frm.sum.value=total;
}
</script>
</head>
<body>
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = strip_tags($_SERVER['php_self']);
?>
<form enctype="multipart/form-data" name="form0" id="form0" action="<?php echo $me; ?>" method="POST">
<table border="0" id="tblSample" align="center">
<tr>
<th colspan="3">
<br>
<br>
<br>
Adding rows then adding up values entered(works fine!)
<br><br>
I need to now echo or print using PHP to pull the new values
<br>
from the newly created price textboxes as an email & results page
<hr>
<input type="button" value="Add new textbox" onclick=
"addRowToTable();">
</th>
</tr>
<tr id="cloneid" >
<td>
1 Item/Price
</td>
<td>
<input type="text" name="t1_1" id="t1_1" size="40">
</td>
<td>
<input type="text" name="t1_2" id="t1_2" size="5" value="" onkeyup="Calc();" onblur="Calc();">
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td colspan="3" align="center">
<br>
<br>
Total: <input type="text" name="sum" id="sum"><br>
<input type="submit" value="E-Mail">
</td>
</tr>
</table>
</form>
<?php
} else {
error_reporting(0);
{$to = "x";
$subject = "php email from customer to me";
$from = $_POST['x'];
$headers = "From: " . $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$msg .= "<body style=\"margin: 5px; font-family: Tahoma, Helvetica, Sans-Serif; font-size: 8pt;\">\n";
$msg .= "<table border=\"0\"><tr><td align=\"right\">";
$msg .= "<b>Item:</b></td><td> " . $_POST['t1_1'] . " \n";
$msg .= "<b>Pice:</b></td><td> " . $_POST['t1_2'] . " \n";
$msg .= "<b>Total:</b></td><td> " . $_POST['sum'] . " \n";
$msg .= "</td></tr></table>";
$msg .= "</body>";
mail($to, $subject, stripslashes($msg), $headers) or die("<p class=\"center\"><strong class=\"red\">ERROR:</strong> Unable To Connect To SMTP Server</p>\n");
echo "<p class=\"center\"><strong class=\"green\">Thank You. Your Order Has Been Processed.</strong></p>\n";
echo "$msg";
}}
?>
</body>
</html>
Any help, much appreciated!!
first line: "t1_1, t1_2"
newly created: "t2_1, t2_2"
newly created: "t3_1, t3_2"
newly created: "t4_1, t4_2"
newly created: "t5_1, t5_2"
newly created: "t6_1, t6_2"
....and so on
I dont want to have to create a line for who knows how many text boxes the customer creates and have to change each one, it would take to long.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Get values from new textbox values
</title>
<script type="text/javascript">
function viewsource() {
alert(document.body.innerHTML);
}
</script>
<script type="text/javascript">
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var frm=document.form0;
if (!frm.ary) frm.ary=[frm.t1_2];
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// numberd row
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// Item row
var cellRight1 = row.insertCell(1);
var el1 = document.createElement('input');
el1.type = 'text';
el1.name = 't' + iteration + '_1';
el1.id = 't' + iteration + '_1';
el1.size = 40;
cellRight1.appendChild(el1);
// Price row
var cellRight2 = row.insertCell(2);
var el2 = document.createElement('input');
frm.ary.push(el2);
el2.type = 'text';
el2.value = '';
el2.name = 't' + iteration + '_2';
el2.id = 't' + iteration + '_2';
el2.size = 5;
el2.onkeyup=Calc;
el2.onblur=Calc;
cellRight2.appendChild(el2);
}
</script>
<script type="text/javascript">
function Calc(){
var frm=document.form0;
if (!frm.ary) frm.ary=[frm.t1_2];
var total=0;
for (var zxc0=0;zxc0<frm.ary.length;zxc0++){
if (frm.ary[zxc0].value.length>0&&!isNaN(frm.ary[zxc0].value)) total+=frm.ary[zxc0].value*1;
}
frm.sum.value=total;
}
</script>
</head>
<body>
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = strip_tags($_SERVER['php_self']);
?>
<form enctype="multipart/form-data" name="form0" id="form0" action="<?php echo $me; ?>" method="POST">
<table border="0" id="tblSample" align="center">
<tr>
<th colspan="3">
<br>
<br>
<br>
Adding rows then adding up values entered(works fine!)
<br><br>
I need to now echo or print using PHP to pull the new values
<br>
from the newly created price textboxes as an email & results page
<hr>
<input type="button" value="Add new textbox" onclick=
"addRowToTable();">
</th>
</tr>
<tr id="cloneid" >
<td>
1 Item/Price
</td>
<td>
<input type="text" name="t1_1" id="t1_1" size="40">
</td>
<td>
<input type="text" name="t1_2" id="t1_2" size="5" value="" onkeyup="Calc();" onblur="Calc();">
</td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td colspan="3" align="center">
<br>
<br>
Total: <input type="text" name="sum" id="sum"><br>
<input type="submit" value="E-Mail">
</td>
</tr>
</table>
</form>
<?php
} else {
error_reporting(0);
{$to = "x";
$subject = "php email from customer to me";
$from = $_POST['x'];
$headers = "From: " . $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$msg .= "<body style=\"margin: 5px; font-family: Tahoma, Helvetica, Sans-Serif; font-size: 8pt;\">\n";
$msg .= "<table border=\"0\"><tr><td align=\"right\">";
$msg .= "<b>Item:</b></td><td> " . $_POST['t1_1'] . " \n";
$msg .= "<b>Pice:</b></td><td> " . $_POST['t1_2'] . " \n";
$msg .= "<b>Total:</b></td><td> " . $_POST['sum'] . " \n";
$msg .= "</td></tr></table>";
$msg .= "</body>";
mail($to, $subject, stripslashes($msg), $headers) or die("<p class=\"center\"><strong class=\"red\">ERROR:</strong> Unable To Connect To SMTP Server</p>\n");
echo "<p class=\"center\"><strong class=\"green\">Thank You. Your Order Has Been Processed.</strong></p>\n";
echo "$msg";
}}
?>
</body>
</html>
Any help, much appreciated!!