On Saturday 18 January 2003 10:50, David Rice wrote: > > 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.
> I believe that if you reference the form element like: > > document.forms['mycell[]'].value > > you will get what you want. Which means you have to give your text elements unique names. IE mycel[0] instead of mycel[] etc. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Today is a good day for information-gathering. Read someone else's mail file. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php