[POO] Calendrier et passage d' objet en parametre
Bonjour,
Voila je voudrais créer un objet javascript Calendrier de facon à l' appeler plusieurs fois dans ma page, l' idée est la suivante :
Code:
1 2 3 4 5
|
<script>
toto = new Calendrier( id, jour, mois, annee );
toto.afficher();
</script> |
Dans cette fonction afficher j' ai un prototype du genre :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
function Calendrier( id, jour, mois, annee ) {
this.id = id;
this.jour = jour;
this.mois = mois;
this.annee = annee;
}
function popc( objet ) {
alert( objet.id );
}
Calendrier.prototype.afficher = function () {
document.write( '<a href="#" onclick="popc( this )">Test</a>' );
} |
Ou alors :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
function Calendrier( id, jour, mois, annee ) {
this.id = id;
this.jour = jour;
this.mois = mois;
this.annee = annee;
}
Calendrier.prototype.popc = function() {
alert( this.id );
}
Calendrier.prototype.afficher = function () {
document.write( '<a href="#" onclick="this.popc()">Test</a>' );
} |
Les deux ne marchent pas et je cherche à passer mon objet en parametre, comment faire ?
j+