Gridwidget - javascript
| From: | Nico Jansen - NiRo IT Consultants B.V. | Date: | Sat, 18 Jan 2003 01:33:01 +0000 |
| Subject: | Gridwidget - javascript | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132057@lists.php.net to get a copy of this message | ||
Hi all,
I'm trying to write a grid widget in php. When the user changes the value of
a cell the totals must be recalculated at the client side.
I can write a javascript when I use simple variables like A1, B1.
<td><input type=text name='A1' SIZE=5 MAXLENGTH=5
onChange="njrecalculate()"></td>
<td><input type=text name='B1' SIZE=5 MAXLENGTH=5
onChange="njrecalculate()"></td>
This javascript will do the trick:
function njrecalculate()
{
document.forms[0].mytot.value = Math.round(document.forms[0].A1.value)
+ Math.round(document.forms[0].B1.value) ;
}
But now I want to create a dynamice grid by using the array variable e.g.
mycell[]:
<?php
echo "<tr><td><input type=text NAME='mycel[]' SIZE=5 MAXLENGTH=5
onChange='njrecalculate()' value=$mycel[0]></td></tr>";
echo "<tr><td><input type=text NAME='mycel[]' SIZE=5 MAXLENGTH=5
onChange='njrecalculate()' value=$mycel[1]></td></tr>";
echo "<tr><td><input type=text NAME='mytotals' SIZE=5 MAXLENGTH=5
onChange='njrecalculate()' value=$mytot></td></tr>";
?>
Does anybody know how to access these mycell form fields on the client side
using javascript.
Nico Jansen