Ahhhh okay. I see now.
So the function the box calls is an AJAX caller…
function select_category(category_id, box_id, prefix, reverse, click_select, listing_type, list_in)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url = relative_path + 'ajax_files/select_category.php';
var action = url + '?category_id=' + category_id + '&target_box_id=' + box_id +
'&prefix=' + prefix + '&reverse_categories=' + reverse + '&click_select=' + click_select +
'&listing_type=' + listing_type + '&list_in=' + list_in;
// xmlHttp.onreadystatechange = function() { showResult(xmlHttp, box_id); };
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4)
{
var response = xmlHttp.responseText;
//document.getElementById(box_id).innerHTML = response;
if (response.indexOf('change_category') == 0 && click_select != true)
{
eval(response);
}
else
{
document.getElementById(box_id).innerHTML = response;
}
}
};
xmlHttp.open("GET", action, true);
xmlHttp.send(null);
}
The onchange (not onclick, btw) code handler is:
select_category(this.value, 'main_category_field', 'main_', 0, false, 'auction', 'auction')
so i tracked this.value…
clicking on the “Select” link returned null for this.value.
clicking on Antiques and Art gave it value 215
clicking on Antiquities gave it value 225.
So now your query string to your page reads:
“ajax_files/select_category.php?category_id=225&target_box_id=addl_category_field&prefix=addl_&reverse_categories=0&click_select=false&listing_type=auction&list_in=auction”
This returns:
change_category(225, ‘addl_’, 0); (or does it?)
which should fire eval(change_category(225, ‘addl_’, 0););
Except… it doesnt. And why does it not?
http://numberthree.netne.net/ajax_files/select_category.php?category_id=225&target_box_id=addl_category_field&prefix=addl_&reverse_categories=0&click_select=false&listing_type=auction&list_in=auction
View Source on that page. You see the extra stuff your host is packing onto the response? Guess what. Javascript tries to run that through eval, and it borks.
What is ACTUALLY going into eval, is: "change_category(225, ‘main_’, 0);\r
<!-- www.000webhost.com Analytics Code –>\r
<script type=\“text/javascript\” src=\“http://analytics.hosting24.com/count.php\\”></script>\r
<noscript><a href=\“http://www.hosting24.com/\\”><img src=\“http://analytics.hosting24.com/count.php\\” alt=\“web hosting\” /></a></noscript>\r
<!-- End Of Analytics Code –>\r
"
Slice off the extra stuff, and it works fine.
PS: Did all this in Firebug. Very handy tool.
PPS: Could have just had the PHP code return the parameters part and straight-called change_category passing it the parameters. Safer than eval.