11548 sujets

JavaScript, DOM et API Web HTML5

Hello, je m'arrache les cheveux avec ceci qui fait une alerte "undefined".


var nbre_lignes = null;
function get_root_submenu(item,show) {
	nbre_lignes++;
	var parent = item.up();
	if (parent.id != 'navigation') {
		get_root_submenu(parent,show);
		return;
	} else {
		if (show==2) {
			item = nbre_lignes -1;
		}
	}
	alert('infunction:'+item); //retourne "infunction:5";
	return item;
}




nbre_lignes= get_root_submenu(item_default,2);
alert ('outfunction:'+nbre_lignes) -->retourne "outfunction:undefined"

Modifié par gordie (02 Dec 2007 - 15:27)