thank you you helped me a lot
thank you very much
Let God Loves you
azegurb 1 Posting Whiz in Training
saiprem 4 Posting Whiz in Training
thank you you helped me a lot
thank you very much
Let God Loves you
You are welcome and Thank you so much...
azegurb 1 Posting Whiz in Training
Hi again
if i dont disturb you (if possible)
how i get from selection options
for ex: i would like to get Motherboard Asus or GrafikCard ATI
what i must do
if you have time pls explain it
Thanks thanks very much
saiprem 4 Posting Whiz in Training
Hi again
if i dont disturb you (if possible)
how i get from selection options
for ex: i would like to get Motherboard Asus or GrafikCard ATI
what i must do
if you have time pls explain it
Thanks thanks very much
You are getting that data in
$_POST["selRow$i"]
If you want it like "Motherboard Asus",
while displaying select box in the form, you need to assign the values for the options as
<option value="Motherboard Asus">Motherboard Asus</option>
azegurb 1 Posting Whiz in Training
no i say that in my example
<?php
@$db=mysql_connect('localhost','238147','19841223');
mysql_select_db('238147');
$i = $_POST['count_rows'];
//echo $i;
for($l=1;$l<=$i;$l++)
{
$amount = $_POST["txtRow$l"];
$price = $_POST["selRow$l"];
$date = '2010-12-12';
$name = $_POST["txtRowe$l"];
$sql="INSERT INTO teze (`id` ,`amount` ,`price` ,`date` ,`name`) VALUES (NULL,'".$amount."','".$price."','".$date."','".$name."')";
$result=mysql_query($sql);
if($result)
{
echo "data entered";
}
else
{
echo "data not entered";
}
}
?>
$price = $_POST["selRow$l"];
this rteruns price
but i need accesuar name not price
saiprem 4 Posting Whiz in Training
no i say that in my example
<?php @$db=mysql_connect('localhost','238147','19841223'); mysql_select_db('238147'); $i = $_POST['count_rows']; //echo $i; for($l=1;$l<=$i;$l++) { $amount = $_POST["txtRow$l"]; $price = $_POST["selRow$l"]; $date = '2010-12-12'; $name = $_POST["txtRowe$l"]; $sql="INSERT INTO teze (`id` ,`amount` ,`price` ,`date` ,`name`) VALUES (NULL,'".$amount."','".$price."','".$date."','".$name."')"; $result=mysql_query($sql); if($result) { echo "data entered"; } else { echo "data not entered"; } } ?>
$price = $_POST["selRow$l"];
this rteruns price
but i need accesuar name not price
I told you the same thing.....
If you need accessory name
you need to add like this in your form
If you want it like "Motherboard Asus",
while displaying select box in the form, you need to assign the
values for the options as
<select name="selRow1" id="selRow1"><option value="MotherBoard ASUS">MotherBoard ASUS</option><option value="MotherBoard Gigabyte">MotherBoard Gigabyte</option><option value="MotherBoard MSI">MotherBoard MSI</option><option value="Graphiqcard ASUS">Graphiqcard ASUS</option><option value="GraphigCard ATI">GraphigCard ATI</option><option value="GraphigCard GefORCE">GraphigCard GefORCE</option></select>
Or if you are retrying the above data from database, you can keep the old select box and
After posting the data, you will get the id of that accessory, then using that id you need to retrieve the data again from the database.
azegurb 1 Posting Whiz in Training
how can i Apply it into my HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>dinamik sheet</title>
<script>
var i=iteration;
function addrow(){
var tbl = document.getElementById('sheet');
var iteration = tbl.rows.length;
document.getElementById('count_rows').value = iteration;
var row=tbl.insertRow(iteration);
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow'+iteration;
el.id = 'txtRow'+iteration;
el.size = 40;
el.value = '0';
el.onblur = sum;
cellRight.appendChild(el);
var cellRight1 = row.insertCell(2);
var ela = document.createElement('input');
ela.type = 'text';
ela.name = 'txtRowe'+iteration;
ela.id = 'txtRowe'+iteration;
ela.size = 40;
ela.value = '0';
ela.onblur = sum;
cellRight1.appendChild(ela);
var cellRightsel = row.insertCell(3);
var sel = document.createElement('select');
sel.name = 'selRow' + iteration;
sel.id = 'selRow' + iteration;
sel.onchange = sum;
sel.options[0] = new Option('MotherBoard ASUS', '150');
sel.options[1] = new Option('MotherBoard Gigabyte', '165');
sel.options[2] = new Option('MotherBoard MSI', '100');
sel.options[3] = new Option('Graphiqcard ASUS', '85');
sel.options[4] = new Option('GraphigCard ATI', '90');
sel.options[5] = new Option('GraphigCard GefORCE', '88');
cellRightsel.appendChild(sel);
sum();
}
function removeRowFromTable()
{
var tbl = document.getElementById('sheet');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
function sum(){
var s1 = 0;
var s2 = 0;
var tbl=document.getElementById('sheet');
var iteration=tbl.rows.length-1;
for(var i=1; i<=iteration; i++){//loop through table rows
var el1 = document.getElementById('txtRow'+i);//Row's Income field
var el2 = document.getElementById('selRow'+i);//Row's percentage menu
var ela = document.getElementById('txtRowe'+i);//Row's Tax cell
if(!el1 || !el2 || !ela) continue;
var txt = el1.value;
if(txt != ( '' + Number(txt) )) continue;//reject non-numeric entries
var tax = Number(txt) * Number(el2[el2.selectedIndex].value);
ela.value = tax.toFixed(2);
s1 += Number(txt);
s2 += tax;
}
var t1 = document.getElementById('total');
var t2 = document.getElementById('taxtotal');
if(t1){ t1.value = s1.toFixed(2); }
if(t2){ t2.value = s2.toFixed(2); }
}
onload = function(){
addrow();
}
</script>
</head>
<body>
<form name="eval_edit" method="POST" action="part1.php?id=iteration-1">
<table align="center" width="75%">
<tr>
<td align="center">Balance sheet</td></tr>
<tr>
<td align="center">
<table id="sheet" border="1">
<tr><td>object</td><td>amount of products</td><td name="amount">amount of price per saled product </td><td>part name</td></tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<input type="hidden" name="count_rows" id="count_rows" />
<input type="button" value="Add" onclick="addrow()" />
<input type="button" value="Remove" onclick="removeRowFromTable()" />
<input type="button" value="SUM" onClick="sum()"/>
<input type="submit" value="Submit" /><br />
</td>
</tr>
<tr>
<td align="left">
<input id="total" name="total" type="text"/>total amount of products<br />
<input id="taxtotal" name="taxtotal" type="text"/>total price of products
</td>
</tr>
</table>
</form>
</body>
</html>
if possible pls make changes on it
saiprem 4 Posting Whiz in Training
In Javascript
find sel.options[0] and from there till sel.options[5] change like below....
sel.options[0] = new Option('MotherBoard ASUS', 'MotherBoard ASUS');
sel.options[1] = new Option('MotherBoard Gigabyte', 'MotherBoard Gigabyte');
sel.options[2] = new Option('MotherBoard MSI', 'MotherBoard MSI');
sel.options[3] = new Option('Graphiqcard ASUS', 'Graphiqcard ASUS');
sel.options[4] = new Option('GraphigCard ATI', 'GraphigCard ATI');
sel.options[5] = new Option('GraphigCard GefORCE', 'GraphigCard GefORCE');
azegurb 1 Posting Whiz in Training
I did it like that
but it gave again error
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>dinamik sheet</title>
<script>
var i=iteration;
function addrow(){
var tbl = document.getElementById('sheet');
var iteration = tbl.rows.length;
document.getElementById('count_rows').value = iteration;
var row=tbl.insertRow(iteration);
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow'+iteration;
el.id = 'txtRow'+iteration;
el.size = 40;
el.value = '0';
el.onblur = sum;
cellRight.appendChild(el);
var cellRight1 = row.insertCell(2);
var ela = document.createElement('input');
ela.type = 'text';
ela.name = 'txtRowe'+iteration;
ela.id = 'txtRowe'+iteration;
ela.size = 40;
ela.value = '0';
ela.onblur = sum;
cellRight1.appendChild(ela);
var cellRightsel = row.insertCell(3);
var sel = document.createElement('select');
sel.name = 'selRow' + iteration;
sel.id = 'selRow' + iteration;
sel.onchange = sum;
sel.options[0] = new Option('MotherBoard ASUS', 'MotherBoard ASUS');
sel.options[1] = new Option('MotherBoard Gigabyte', 'MotherBoard Gigabyte');
sel.options[2] = new Option('MotherBoard MSI', 'MotherBoard MSI');
sel.options[3] = new Option('Graphiqcard ASUS', 'Graphiqcard ASUS');
sel.options[4] = new Option('GraphigCard ATI', 'GraphigCard ATI');
sel.options[5] = new Option('GraphigCard GefORCE', 'GraphigCard GefORCE');
cellRightsel.appendChild(sel);
sum();
}
function removeRowFromTable()
{
var tbl = document.getElementById('sheet');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
function sum(){
var s1 = 0;
var s2 = 0;
var tbl=document.getElementById('sheet');
var iteration=tbl.rows.length-1;
for(var i=1; i<=iteration; i++){//loop through table rows
var el1 = document.getElementById('txtRow'+i);//Row's Income field
var el2 = document.getElementById('selRow'+i);//Row's percentage menu
var ela = document.getElementById('txtRowe'+i);//Row's Tax cell
if(!el1 || !el2 || !ela) continue;
var txt = el1.value;
if(txt != ( '' + Number(txt) )) continue;//reject non-numeric entries
if(Number(el2[el2.selectedIndex].value)=="MotherBoard ASUS")
var tax = Number(txt) * Number(150);
elseif(Number(el2[el2.selectedIndex].value)=="MotherBoard Gigabyte")
var tax = Number(txt) * Number(165);
elseif(Number(el2[el2.selectedIndex].value)=="MotherBoard MSI")
var tax = Number(txt) * Number(100);
elseif(Number(el2[el2.selectedIndex].value)=="Graphiqcard ASUS")
var tax = Number(txt) * Number(85);
elseif(Number(el2[el2.selectedIndex].value)=="GraphigCard ATI")
var tax = Number(txt) *Number( 90);
else(Number(el2[el2.selectedIndex].value)=="GraphigCard GefORCE")
var tax = Number(txt) * Number(88);
ela.value = tax.toFixed(2);
s1 += Number(txt);
s2 += tax;
}
var t1 = document.getElementById('total');
var t2 = document.getElementById('taxtotal');
if(t1){ t1.value = s1.toFixed(2); }
if(t2){ t2.value = s2.toFixed(2); }
}
onload = function(){
addrow();
}
</script>
</head>
<body>
<form name="eval_edit" method="POST" action="part1.php?id=iteration-1">
<table align="center" width="75%">
<tr>
<td align="center">Balance sheet</td></tr>
<tr>
<td align="center">
<table id="sheet" border="1">
<tr><td>object</td><td>amount of products</td><td name="amount">amount of price per saled product </td><td>part name</td></tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<input type="hidden" name="count_rows" id="count_rows" />
<input type="button" value="Add" onclick="addrow()" />
<input type="button" value="Remove" onclick="removeRowFromTable()" />
<input type="button" value="SUM" onClick="sum()"/>
<input type="submit" value="Submit" /><br />
</td>
</tr>
<tr>
<td align="left">
<input id="total" name="total" type="text"/>total amount of products<br />
<input id="taxtotal" name="taxtotal" type="text"/>total price of products
</td>
</tr>
</table>
</form>
</body>
</html>
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.