The reason why... (I think) Id defines the element as a part of the DOM - it is the identifier of the element Name tells the browser the name of the parameter (i.e. the mane to associate with the value), not of the element. PHP and JS are looking for two different things - one wants the element, one the parameter - so it makes sense (sort of) to use two different terms. Simcha Younger -----Original Message----- From: tedd [mailto:tedd.sperling@xxxxxxxxx] Sent: Thursday, August 28, 2008 4:40 PM To: php-general@xxxxxxxxxxxxx Subject: RE: Re: Variable name as a string At 11:50 AM +0100 8/28/08, Ford, Mike wrote: >On 28 August 2008 00:04, tedd advised: > > > One of the ways to get around this is to: >> >> <input type="checkbox" name="my_checkboxes[]" >> id="my_checkbox_1" value="1" > > > >> That way php will use "name" and javascript will use "id". > >Why??? > > <form name="my_form" ... > > <input type="checkbox" name="my_checkboxes[]" ... > > </form> > > <script language="Javascript"> > checkboxes = document.my_form["my_checkboxes[]"]; > </script> > >Cheers! > >Mike Mike: There is no "Why?", this is just another way to do it. In fact, there are other ways to accomplish this than what both of us have shown. What's nice about the technique I described here, at least for me, is that the "value" attribute applies to both name and id. PHP uses name and javascript uses id -- it's simple. However, I've been leaning to using getElementById() to create unobtrusive javascript, which can be used to isolate and use "name" as well, thus reducing the html code. I think my next demo will be to show these various techniques. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.10/1638 - Release Date: 27/08/2008 19:06 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php