fichier contenant fonction
Bonjour,
Sur des éléments html j'ai des "onchange", "onload", "onclick" etc.
Quelle est la meilleure façon pour externaliser toutes ces fonctions dans un fichier js séparé ? (sachant que j'ai besoin parfois de passer des paramètres...)
pour le moment j'ai un fichier avec un contenu de ce style :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| window.onload = function() {
document.getElementById('un_id').onclick = function() {
alert('Not implemented yet !');
return false;
};
document.getElementById('encore_un_id').onclick = function() {
alert('Hello le monde !');
return false;
};
document.getElementById('id').onchange = function(parametre) {
if (parametre === 1)
alert('OK !');
return false;
};
}; |
Quand je n'ai pas de paramètre a passer, c'est nickel ! Quand j'en ai comme la dernière fonction, comment dois-je m'y prendre ?