I think you must bind the blur event inside the change event, otherwise it would never work - i.e. you have to unbind the old blur event, and create a new one, because your connection thingie changed. I think the following code might help:
function bindConnection( prevConnId, currConnId ) {
if( prevConnId ) {
$('#'+prevConnId+' :input').off( "blur ");
}
$('#'+currConnId+' :input').on( "blur", function(e) {
alert( currConnId );
if(!$(e.currentTarget).val() == "") {
service_info = $(e.currentTarget).val(); //Innehåller värdet i input-fälten
id = $(e.currentTarget).attr('id');
service = currConnId;
$.ajax({
type: 'GET',
url: 'summary.php',
data: {service_info: service_info, id: id, service: service},
dataType: "html",
success: function(data) { $('#table_right #services_'+currConnId).html(data); },
error: function(xhr, ajaxOptions, thrownError) { alert(thrownError); }
});
}
});
}
$('.type_of_connection').change(function(e) { //Visa vald tjänst och dess tillhörande div. Varje tjänst har en egen div.
var show_connection = 1;
connection = $(this).val(); //Innehåller VILKEN tjänst man har valt ENGLIS: The option you choosed
bindConnection( $.cookie("cookie_connection"), connection ); //unbind event for previous connection, and bind new one
$.cookie("cookie_connection", connection);
var divbox = null; //Innehåller id:et på den div som skall visas.
if(connection == "nao_lan") {
divbox = "services_naolan";
} else if(connection == "stadsnat") {
divbox = "services_stadsnat";
} else if(connection == "vadsl") {
divbox = "services_vadsl";
} else if(connection == "tele") {
divbox = "services_tele";
} else {
divbox = null;
}
$.ajax({
type: 'GET',
url: 'summary.php',
data: {connection: connection, show_connection: show_connection},
dataType: "html",
success: function(data) { $("#table_right #" + divbox).html(data).show(); },
error: function(xhr, ajaxOptions, thrownError) { alert(thrownError); }
});
});
bindConnection( null, $.cookie('cookie_connection') ); //bind the first connection