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 :
Dans cette fonction afficher j' ai un prototype du genre :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <script> toto = new Calendrier( id, jour, mois, annee ); toto.afficher(); </script>
Ou alors :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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>' ); }
Les deux ne marchent pas et je cherche à passer mon objet en parametre, comment faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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>' ); }
j+
Partager