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

Reply via email to