calculate a mark up

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a column of #'s i want to add 20% to each # and store it in a new
column
i can get it to calculate 1 cell but cant get it to calculate the remaining
cells.
whats wrong
 
How are you doing this? With JavaScript, ASP etc? Is there a URL where we
can see what's happening? If not, can you paste the code into a reply?
 
jlowry said:
i have a column of #'s i want to add 20% to each # and store it in
a new column
i can get it to calculate 1 cell but cant get it to calculate the
remaining cells.
whats wrong

Here is one way to do it.
This rounds to 1 decimal place
To round to 2 d.p., use
document.getElementById(row2).value
= Math.round(document.getElementById(row1).value * 120) /100

When the number of rows increases, use ids in the same pattern,
e.g. elt71 elt72, etc
and alter the maximum value of i in
for (i= 1 ; i <= 6; i++)
e.g. when it is 8:
for (i= 1 ; i <= 8; i++)

Whether it is what you want or not, I can't be sure

<html>
<head>
<script type="text/javascript">
function doit()
{
for (i= 1 ; i <= 6; i++)
{
var row = 'elt' + i
document.getElementById(row + '2').value
= Math.round(document.getElementById(row + '1').value * 120) /100
}
}
</script>
</head>
<body>
<form name="myForm" action="" style="margin-top:0">
<table>
<tr>
<td><input type="text" id="elt11" size="10" value="1"></td>
<td><input type="text" id="elt12" size="10" value=""></td>
</tr>
<tr>
<td><input type="text" id="elt21" size="10" value="267"></td>
<td><input type="text" id="elt22" size="10" value=""></td>
</tr>
<tr>
<td><input type="text" id="elt31" size="10" value="3.33"></td>
<td><input type="text" id="elt32" size="10" value=""></td>
</tr>
<tr>
<td><input type="text" id="elt41" size="10" value="4.761"></td>
<td><input type="text" id="elt42" size="10" value=""></td>
</tr>
<tr>
<td><input type="text" id="elt51" size="10" value="5.25"></td>
<td><input type="text" id="elt52" size="10" value=""></td>
</tr>
<tr>
<td><input type="text" id="elt61" size="10" value="6.345"></td>
<td><input type="text" id="elt62" size="10" value=""></td>
</tr>
</table>

<input type="button" value="Compute" onclick="doit()"></td>

</form>
</body>
</html>
 
thanks - i got it posted in the wrond place.
i am using exel - made a post there and got my answer
thanks.
 
Back
Top