$(document).ready(function() {
//$('#loader').hide();
$('.player1').livequery('change', function() {
$(this).nextAll('.parent').remove();
$(this).nextAll('label').remove();
$('#characters1').empty();
$('#characters1').append('<img src="loader.gif" style="float:left; margin-top:7px;" id="loader" alt="" />');
$.post("get_characters.php", {
player_id: $(this).val(),
player: $(this).attr('player'),
}, function(response){
setTimeout("finishAjax('characters1', '"+escape(response)+"')", 400);
});
return false;
});
function finishAjax(id, response){
$('#loader').remove();
$('#'+id).append(unescape(response));
}
Okay, I have a php loop that creates drop down lists automatically. Now I have the Javascript to dynamically update another drop down based on the previous drop down's selection. Now here is my issue there are 25 pairs drop downs in php which are created with unique drop downs with the id 'player#' and dynamically update the 'character#' with a drop down on change. Now I would like for the javascript to be able to interpret which id is which so that it only modifies the linked to it. I can achieve this by essentially by writing the script over 25 times with the proper id's but that seems to be such a waste of code. Is there any way to do this similar to a php's while function? Thanks in advance!