A
Azik
Hello, I have one question
i created table and in this table i added some another options
for ex at the previous table there were only one problem sum of the
dynamically added rows
in this beside sum i need to sum of the percent of this sum
for ex 10% of this dynamically added rows
for ex. i added ten rows and i entered different values into these
rows. in front of each row there are different option of percent
selection.
in row1 i added 1000 and chose from drop down box 10%
in row2 i added 2500 and chose from drop down box 30%
..............................................................
and so on
and finally i summed separately sum of the values and sum percentage
of this values to other texbox value
if possible help me
thanks beforehands
here is code
<html><head><title>dinamik sheet</title>
<script>
function addrow(){
var tbl=document.getElementById('sheet');
var lastrow=tbl.rows.length;
var iteration=lastrow;
var row=tbl.insertRow(lastrow);
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.size=40;
el.setAttribute('sumMe',"1");
cellRight.appendChild(el);
var cellRight2=row.insertCell(2);
var el1=document.createElement('input');
el1.type='text';
el1.name='txtRowe'+iteration;
el1.size=40;
el1.setAttribute('sumMe',"1");
cellRight2.appendChild(el1);
var cellRightsel=row.insertCell(3);
var sel=document.createElement('select');
sel.name='selRow'+iteration;
sel.options[0]=new Option('10%','value0');
sel.options[1]=new Option('20%','value1');
sel.options[2]=new Option('30%','value2');
cellRightsel.appendChild(sel);
var cellRightsel2=row.insertCell(4);
var sel1=document.createElement('input');
sel1.type='button';
sel1.value='sum row'+iteration;
sel1.name='button'+iteration;
cellRightsel2.appendChild(sel1);
}
</script>
<script>
function sum(){
var form=document.getElementById('eval_edit');
if(!form) return;
var fields=form.getElementsByTagName('input');
var s=0;
for (var i=0;i<fields.length;i++){
if( fields.getAttribute('sumMe') != "1" ) continue;//reject
any field not carring the "sumMe" attribute
var txt = fields.value;
if(txt != ( '' + Number(txt) )) continue;//reject non-numeric
entries
s += Number(txt);
}
if(form['total']){ form['total'].value = s; }
}
onload = function(){
sum();
}
</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 border="1" id="sheet"><tr><td>object</td><td>Income</td><td>Tax
from income</td><td>instruktor</td></tr>
<td><select name="selRow0">
<option value="value0">10%</option>
<option value="value1">20%</option>
<option value="value2">30%</option></select></td><td><input
type="button" name="button1" value="sum row1" id="button1"></tr></
table>
INCOME SUM<input name="total" type="text"/>
<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" /> <input name="taxtotal"
type="text"/>Tax SUM with desirable percent for ex: 20%
</td>
</tr>
</table>
</form>
</body>
</html>
i created table and in this table i added some another options
for ex at the previous table there were only one problem sum of the
dynamically added rows
in this beside sum i need to sum of the percent of this sum
for ex 10% of this dynamically added rows
for ex. i added ten rows and i entered different values into these
rows. in front of each row there are different option of percent
selection.
in row1 i added 1000 and chose from drop down box 10%
in row2 i added 2500 and chose from drop down box 30%
..............................................................
and so on
and finally i summed separately sum of the values and sum percentage
of this values to other texbox value
if possible help me
thanks beforehands
here is code
<html><head><title>dinamik sheet</title>
<script>
function addrow(){
var tbl=document.getElementById('sheet');
var lastrow=tbl.rows.length;
var iteration=lastrow;
var row=tbl.insertRow(lastrow);
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.size=40;
el.setAttribute('sumMe',"1");
cellRight.appendChild(el);
var cellRight2=row.insertCell(2);
var el1=document.createElement('input');
el1.type='text';
el1.name='txtRowe'+iteration;
el1.size=40;
el1.setAttribute('sumMe',"1");
cellRight2.appendChild(el1);
var cellRightsel=row.insertCell(3);
var sel=document.createElement('select');
sel.name='selRow'+iteration;
sel.options[0]=new Option('10%','value0');
sel.options[1]=new Option('20%','value1');
sel.options[2]=new Option('30%','value2');
cellRightsel.appendChild(sel);
var cellRightsel2=row.insertCell(4);
var sel1=document.createElement('input');
sel1.type='button';
sel1.value='sum row'+iteration;
sel1.name='button'+iteration;
cellRightsel2.appendChild(sel1);
}
</script>
<script>
function sum(){
var form=document.getElementById('eval_edit');
if(!form) return;
var fields=form.getElementsByTagName('input');
var s=0;
for (var i=0;i<fields.length;i++){
if( fields.getAttribute('sumMe') != "1" ) continue;//reject
any field not carring the "sumMe" attribute
var txt = fields.value;
if(txt != ( '' + Number(txt) )) continue;//reject non-numeric
entries
s += Number(txt);
}
if(form['total']){ form['total'].value = s; }
}
onload = function(){
sum();
}
</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 border="1" id="sheet"><tr><td>object</td><td>Income</td><td>Tax
from income</td><td>instruktor</td></tr>
size="40"/></td></td><td><input sumMe="1" type="text" name="txtrowe" id="txtrowe"
<td><select name="selRow0">
<option value="value0">10%</option>
<option value="value1">20%</option>
<option value="value2">30%</option></select></td><td><input
type="button" name="button1" value="sum row1" id="button1"></tr></
table>
INCOME SUM<input name="total" type="text"/>
<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" /> <input name="taxtotal"
type="text"/>Tax SUM with desirable percent for ex: 20%
</td>
</tr>
</table>
</form>
</body>
</html>