azegurb 1 Posting Whiz in Training

Hi, i created dynamic table with a help JavaScript master (Airshow)
which add rows automatically and sums each added row. and so on
here is my code.
Please help me to send it to MySQl base via PHP
Thanks beforehand

<html>
<head><title>dinamik sheet</title>
<script> 
function addrow(){
	var tbl = document.getElementById('sheet');
	var iteration = tbl.rows.length;
	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);
	cellRight1.id = 'txtRowe'+iteration;
 
	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('10%', '10');
	sel.options[1] = new Option('20%', '20');
	sel.options[2] = new Option('30%', '30');
	cellRightsel.appendChild(sel);
	sum();
}
 
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 el3 = document.getElementById('txtRowe'+i);//Row's Tax cell
		if(!el1 || !el2 || !el3) continue;
		var txt = el1.value;
		if(txt != ( '' + Number(txt) )) continue;//reject non-numeric entries
		var tax = Number(txt) * Number(el2[el2.selectedIndex].value)/100;
		el3.innerHTML = 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">
<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>Income</td><td>Tax from income</td><td>instruktor</td></tr>
	</table>
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="Add" onclick="addrow()" />
<input type="button" value="Remove" onclick="removeRow()" />
<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"/>&nbsp;INCOME SUM<br />
<input id="taxtotal" name="taxtotal" type="text"/>&nbsp;Tax SUM with desirable percent for ex: 20%
</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.