
July 18th, 2000, 02:43 PM
|
|
Junior Member
|
|
Join Date: Jul 2000
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
OK, I put this problem aside for awhile and came back to it today. It may be useful to some of you that are working with Javascript and PHP, so I'll let you know what I came up with.
PHP allows form variables with the same name ending in empty square brackets to be sent to php as an array (e.g. <input type=select name = "mylist[]"> ) This is just plain handy.
Recently I was using javascript to move items between two lists and wanted to send the content of one of the lists (very similar to a shopping cart) to my script as an array. My scripts kept failing if I named my item 'list2[]' because javascript thinks list2[] is an object which should have properties.
In my case, the action was all within the same form, so I was able to get around this by referring to the select lists as this.form['list2[]'] when I needed to past the select list as an argument to javascript.
|