davefederici
02-20-2007, 06:26 PM
I have a database results that displays 3 text boxes across a table and as
many rows as the query returns. I have a function that will allow you to
enter a number in the first and second textbox then the function will add the numbers together and display it in the third textbox but it wont work if I
display more than one row. I need to know how to code the textboxes and
the function so It will increment the name values down the table here is a
sample of the function I am using
<script language="javascript">
function Totals() {
with (document.forms["form1"])
{
var total1 = Number( box1.value ) + Number( box2.value );
box3.value = total1;
}
}
</script>
the html code is
<table border="1" width="100%" id="table1">
<tr>
<td><input onblur=Totals() type=text name=box1 value=1></td>
<td><input onblur=Totals() type=text name=box2 value=1></td>
<td><input type=text name=sub_total value="?" readonly onfocus="this.blur()"></td>
<td> </td>
</tr>
<tr>
I dont show the database query that generates the rows
but I think box1 needs box1++1 or something. Please help if you can
Thanks
Dave
many rows as the query returns. I have a function that will allow you to
enter a number in the first and second textbox then the function will add the numbers together and display it in the third textbox but it wont work if I
display more than one row. I need to know how to code the textboxes and
the function so It will increment the name values down the table here is a
sample of the function I am using
<script language="javascript">
function Totals() {
with (document.forms["form1"])
{
var total1 = Number( box1.value ) + Number( box2.value );
box3.value = total1;
}
}
</script>
the html code is
<table border="1" width="100%" id="table1">
<tr>
<td><input onblur=Totals() type=text name=box1 value=1></td>
<td><input onblur=Totals() type=text name=box2 value=1></td>
<td><input type=text name=sub_total value="?" readonly onfocus="this.blur()"></td>
<td> </td>
</tr>
<tr>
I dont show the database query that generates the rows
but I think box1 needs box1++1 or something. Please help if you can
Thanks
Dave