Ad Code

OnLoad and OnChange - jQuery

Just put it in a function, then call it on document ready too, like so:
$(function () {
    yourFunction(); //this calls it on load
    $("select#marca").change(yourFunction);
});

function yourFunction() {
    var marca = $("select#marca option:selected").attr('value');
    $("select#modello").html(attendere);
    $.post("select.php", {id_marca:marca}, function(data){
        $("select#modello").html(data);
    });
}

Not entirely sure if this is what you're looking for, but if you were hoping to run the safe() code when the page loads, try this.
$(function() {

    function safe(){
        if( this.checked ){
            $("select[name='sort']").attr("disabled", "disabled");
            $("input[name='group']").attr("disabled", "disabled")
        } else {
            $("select[name='sort']").attr("disabled", false);
            $("input[name='group']").attr("disabled", false)
        }
    }
    $('input#safe').change(safe).triggerHandler("change");

});
Uses .triggerHandler() to fire the handler without changing the state.

Post a Comment

0 Comments