Chained Selects Step-by-step: Implement list group for select list arrays

Many server side scripts support form element arrays and usually those elements are named as, for example, cars[]:

<select name="cars[]">
...
<select name="cars[]">

so that the server script can refer to them as cars[0], cars[1], etc.

If you have multiple sets of select lists that share the same list content, like the following:

<select name="makes[]">
<select name="types[]">
<select name="models[]">
...
<select name="makes[]">
<select name="types[]">
<select name="models[]">

and your server script would refer to them as makes[0], types[0] and models[0], ..., makes[n], types[n] and models[n], then you can use the initListGroups() call once instead of using the initListGroup() call many times, like this:

<body onload="initListGroups('vehicles', document.forms[0]['makes[]'], document.forms[0]['types[]'], document.forms[0]['models[]'])">

The 'cookie-name' and callback-function parameters will also work with the initListGroups() call.

Click [ here ] to see a demo page.

[ Set up option groups in a list group ] [ Back to main page ]

# # #