Re: Multiselect List. .
| From: | Martin Norland | Date: | Wed, 18 May 2005 22:11:17 +0000 |
| Subject: | Re: Multiselect List. . | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-39498@lists.php.net to get a copy of this message | ||
Patel, Aman wrote:
Ryan Jameson (USA) wrote:An addendum to that, two points: (mixed js and html examples, patently obvious which is which though) 1) You can use this for more than just form elements, if you give an item an id. e.g. <div id="my_great_div">hello world</div> h8_ie_my_great_div = MM_findObj("my_great_div"); 2) This is just a general warning, but I used to stumble into it a lot. IE creates variables/objects in the document namespace, essentially polluting it - good for convenience, bad for cross-browser anything. As an example: <input name="nothing"> can be used as just "nothing" e.g.: alert(nothing); ... and in fact, you get errors when you try to do things like: nothing = MM_findObj("nothing"); because IE doesn't like to overwrite its pretty little objects. Which nobody asked for. The only solution is to use different names for the javascript variables describing/referring to your form/other elements. h8_ie_nothing = MM_findObj("nothing"); cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.That's not the problem. The problem is referring to the listbox via javascript. It doesn't like the format: formName.listBoxName[].value it has no problem with formName.listBoxName.value but then PHP doesn't seem to handle it correctly.There is a function called "MM_findObj" which does exactly what you need. I believe it originated from the Macromedia company (hence the MM prefix) - possibly used by Dreamweaver for its scripting purposes, but I digress. Below is the funtion, and whenever you want to refer to oddly named form elements, you call MM_findObj('oddlyNamedFormElement[]') (and it returns an object reference to the form element that you can use normally). [snip]