note 11213 deleted from language.types.array by curt

From: Date: Tue, 06 Jul 2004 02:08:24 +0000
Subject: note 11213 deleted from language.types.array by curt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72640@lists.php.net to get a copy of this message
Note Submitter: info@knomaze.com ---- PHP, HTML & Javascript To say I was bashing my head against the wall for 6 days on this is an understatement - niaht (niaht@logicfactor.com) helped me find a partial answer to this nagging problem: FAQ Section 8.1 states that we can set the name element in an input object to an array as indicated: <input name="MyArray[]"> <input name="MyArray[]"> <input name="MyArray[]"> This produces a array that gets sent to the PHP script when the form returns. Further, that you must not use indices with arrays in HTML! Well based upon my recent experience with PHP4 - leaving the indices out may not necessarily be the best thing, especially when dealing with two dimensional arrays. Further, IE and Netscape do not handle the resulting element name in the same way. Although we found a method that worked in IE, it didn't work for Netscape and as I am a fan of finding single solutions that work for both browsers, here is a way that you can reference these variables in Javascript. document.forms.formname.element[i].value This will work regardless of which browser you are using. The drawback is that it may take some manual effort to find the right index value for "i" the first time around. The javascript book I have here suggests that in the application I've been working on, the elements I am interested in started at element[6] - in fact they started at element[7] for both IE and NS, so it would be wise to cross check the indices before trying this at home.

« previous php.notes (#72640) next »