hi, this is not exactly a jquery question but it could be useful
anyway.

i've got a function to which i pass 4 parameters, two as values, two
as var references, but which are 'spelt' the same. Is there a way i
can pass only two parameters and use them inside the function once as
a value and once as var reference

loadSelect('cat', cat, 'fam', fam);  // these are the 4 parameters:
how can i call it using only 2, ie: loadSelect('cat', 'fam'); or
loadSelect(cat, fam);


function loadSelect(parent, parentVal, target, targetVal){
        var url = '../include/select.php?search=' + parent;
        var target = '#' + target;
        $.getJSON(url,{q: parentVal}, function(j){
                var options = '';
                for (var i = 0; i < j.length; i++) {
                        options += '<option value="' + j[i].oV + '"';
                        if ( j[i].oV == targetVal) {
                                options += 'selected="selected"';
                                if (parent == 'cat') loadSelect('fam', fam, 
'cod', cod);
                        }
                        options += '>' + j[i].oT;'</option>';
                }
                $(target).html(options);
        });
}

Reply via email to