Multiple select boxes, hot to identify

Multiple select boxes, hot to identify

Hi there!

I'm a newbie with jQuery and found this forum today.

I'm a web developer (mysql-php mostly) in the Netherlands. My apologies in advance for any bad English.

I'm trying to build a page which has multiple chain-selects of the same category.

I've managed to populate only one box.
Now the next step, multiple boxes.

javascript:

<script type="text/javascript">
$(document).ready(function(){
// $("#selectionresult1").hide();

$("#selection").change( function() {
$("#selectionresult1").hide();
$("#result").html('Retrieving ...');
$.ajax({
type: "POST",
data: "data=" + $(this).val(),
url: "cats.php",
success: function(msg){
if (msg != ''){
$("#selectionresult1").html(msg).show();
$("#result").html('');
}
else{
$("#result").html('<em>No item result<\/em>');
}
}
});
});
});
</script>

This script makes use of the id in the select statement.
I'm looping the select boxes in an PHP page, with a counter on the id and making a array for posting all the data.

it looks similar to this:

<select name="mainmenu[]" size="5" id="selection'.$i.'">
QUERY FOR OPTIONS
</select>

<select name="submenu[]" size="5" id="selectionresult'.$i.'"></select>
<span id="result">&nbsp;</span>

The first of the loop obviously works cause the id identifier is the same.

My question, how can I improve the method of identifying so i can use multiple chain selects on one page.

I hope I've written this clear, please don't hesitate to ask for more details, any help is welcome.

Best Regards,

Michael