Topic: Problem using Xajax to call client JS function to change SELECT
G'day. Having a head-scratcher on combining a $or->script call of client JS function to change SELECT menu selected index. Sometimes it works, sometimes is doesn't. Using Firefox's console thingie, I can manually run client JS function and it works everytime.
XAJAX PHP:
Code: PHP
$or->script("selectOpt('gradyear','{$arr['gradyear']}'); selectOpt('posO','{$arr['posO']}'); selectOpt('posD','{$arr['posD']}'); selectOpt('team_id','{$arr['team_id']}');");
Client JS (utilizing latest Prototype):
Code: PHP
function selectOpt(s,v){
if(v !== ''){
var e = $(s);
for(var i = 0; i < e.options.length -1; i++){
if(e.options[i].value==v){
e.selectedIndex = i;
}
}
}
}
One of the SELECT menus in question has more than 600 options, so I'd rather not regenerate the menu each time and assign the HTML to a DIV. I feel like I'm close here, but feeling a bit stumped.
Oh, the DIV containing the FORM and various SELECTs is being displayed in a Modalbox dropdown, but like I said, manually through the console works fine.