RE: [PHP] Not sure

From: Date: Fri, 14 May 2004 10:07:29 +0000
Subject: RE: [PHP] Not sure
Groups: php.general 
Request: Send a blank email to php-general+get-186223@lists.php.net to get a copy of this message
On 14 May 2004 09:59, Brent Clark wrote: > Hi all > > I have the following php code: > > echo"<td>&nbsp;</td><td><input type=\"checkbox\" > name=\"frow\" > value=\"$var\"></td>\n"; > > I now have the following javascript code: > <!-- From webmin--> > > <a href='' onClick='document.frm.frow.checked = true; for(i=0; > i<document.frm.frow.length; i++) { > document.frm.frow[i].checked = true; } > return false'>Select all</a>&nbsp; > <a href='' onClick='document.frm.frow.checked = > !document.frm.frow.checked; > for(i=0; i<document.frm.frow.length; i++) { > document.frm.frow[i].checked = > !document.frm.frow[i].checked; } return false'>Invert > selection</a><br> > > the problem I have is that if I change the > > echo"<td>&nbsp;</td><td><input type=\"checkbox\" > name=\"frow\" > value=\"$var\"></td>\n"; to > echo"<td>&nbsp;</td><td><input type=\"checkbox\" > name=\"frow[]\" > value=\"$var\"></td>\n"; > > Then my php task is fine, but if I make it a normal variable, like > name="frow" > > But then my PHP does not work, and the Javascript does work (Selects > all the checkboxes with a tick) > > I can determine if this is a javascript fault or a php fault. Neither -- a programmer fault! ;) Name the field with name="frow[]", and refer to it in JavaScript like this: document.frm['frow[]'] Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#186223) next »