Y a t-il une façon de procéder particulière pour inclure un fichier js dans un fichier phtml ?
Mon fichier phtml se trouve ici :
Mon fichier js est ici :C:\wamp_v2.0\www\test2\application\views\scripts\index\index.phtml
Voici le contenu mon fichier index.phtml :C:\wamp_v2.0\www\test2\application\views\scripts
Vous remarquerez l'appel au fichier js que j'ai mis en évidence.
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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 <style> a:link, a:visited { color: #0398CA; } span#zf-name { color: #91BE3F; } div#welcome { color: #FFFFFF; background-image: url(http://framework.zend.com/images/bkg_header.jpg); width: 600px; height: 400px; border: 2px solid #444444; overflow: hidden; text-align: center; } div#more-information { background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif); height: 100%; } </style> <h1> coucou </h1> <script type='text/javascript' src="../calc-selector.js"></script> <input type="button" name="calculer" value="Tester" onClick="tester();"> <form name="calculateurimc" method="post" action="Index/imc"> <table width="400px" height="91px"> <tbody> <tr> <td width="400" valign="top" align="center" rowspan="1" colspan="3"> <h1>Calculateur IMC</h1> </td> </tr> <tr> <td width="400" valign="top" align="center"> Taille (en cm) : <input type="text" maxlength="5" size="5" name="taille"> </td> <td width="400" valign="top" align="center"> Poids : <input type="text" maxlength="5" size="5" name="poids"> </td> </tr> <tr> <td width="400" valign="top" align="right" rowspan="1" colspan="3"> <input type="submit" name="calculer" value="Calculer IMC"> </td> </tr> <tr> <td width="400" valign="top" align="center"> Imc : <input type="text" maxlength="5" size="5" name="imc"> </td> </tr> </tbody> </table> </form>
Enfin, voilà le contenu du fichier calc-selector.js :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 function tester() { alert("test"); }
Quand je clique sur mon bouton "Tester", la fonction "Tester()" n'est pas appelée.
Je précise que quand je déclare ma fonction dans le fichier phtml même (dans une balise script), elle est bien appelée.
Partager