Re: Multiselect List. .

From: Date: Wed, 18 May 2005 20:40:13 +0000
Subject: Re: Multiselect List. .
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-39494@lists.php.net to get a copy of this message
Ryan Jameson (USA) wrote:
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). function MM_findObj(n, d) { //v4.01 var p, i, x; if (!d) { d = document; } if ((p = n.indexOf('?')) > 0 && parent.frames.length) { d = parent.frames[n.substring(p+1)].document; n = n.substring(0,p); } if (!(x = d[n]) && d.all) { x = d.all[n]; } for (i = 0; !x && i < d.forms.length; i++) { x = d.forms[i][n]; } for (i = 0; !x && d.layers && i < d.layers.length; i++) { x = MM_findObj(n, d.layers[i].document); } if(!x && d.getElementById) { x=d.getElementById(n); } return x; }

« previous php.db (#39494) next »