this.value is easier.
'sub_cat_selector.php?id='+this.value
Have you checked that sub_cat_selector.php is being invoked? With the right ID? And is correctly doing whatever it's supposed to be doing?
[edit] Oh, and remove the "javascript:" from the onchange. That's only for link hrefs. onchange contains Javascript code already, you don't have to tell it again.
And actually that may be the problem...
[edit 2] Oh, and try to avoid inline Javascript. If you have something like jQuery then you can quite easily do a
<select name="top_cat<?php echo $r['product_id'];?>" id="top_cat<?php echo $r['product_id'];?>" class="top_cat">
$(function() {
$("select.top_cat").change(function() {
MyAjaxRequest(this.id.replace(/top_cat/, "sub_cat_selector"), "sub_cat_selector.php?id=" + this.value);
});
});
Edited by requinix, 05 February 2013 - 03:37 PM.