Précédent   Forum des professionnels en informatique > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 16/07/2007, 15h40   #1
Invité de passage
 
Inscription : octobre 2006
Messages : 14
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 14
Points : 0
Points : 0
Par défaut [PHP-JS] comment exécuter une fonction javascript avec code php

Bonjour

Je voudrais exécuter une fonction javascript [valide2()] dans un code php mais je n’arrive pas.
si quelqu’un peux m’aider a résoudre, Merci.
red_nour est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/07/2007, 15h47   #2
Membre Expert
 
Inscription : janvier 2005
Messages : 2 288
Détails du profil
Informations forums :
Inscription : janvier 2005
Messages : 2 288
Points : 2 287
Points : 2 287
Ca n'est pas possible, PHP est exécuté coté serveur et javascript coté client.
Donc soit tu appelles la fonction coté client avant d'envoyer les résultats au serveur. Soit en php tu prévois à l'avance l'appel futur à la fonction valide2()

Je me trompe peut etre mais dans ton cas ta fonction servira-t-elle a valider un formulaire ou un champ de formulaire avant soumission?

*Donnes nous plus d'informations sur ton probleme actuel ainsi que du code d'exemple qu'on puisse t'aiguiller.
koopajah est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/07/2007, 16h04   #3
Invité de passage
 
Inscription : octobre 2006
Messages : 14
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 14
Points : 0
Points : 0
voila la fonction valide2() :
Code :
1
2
3
4
5
6
7
8
9
10
11
function valide2()
{
v=document.getElementById('annuler').value;
 
if(v =='a')
	{
		alert("rednour test ok ==== "+document.getElementById('annuler').value)	;
document.getElementById('left_col').innerHTML = file('tableauxleft.php');
document.getElementById('Planning.php').innerHTML = file('Planning.php?i=4&m='+document.getElementById('mmm').value+'&y='+document.getElementById('yyy').value);
	}
};
je veux exécuter la fonction après l'envoie du formulaire pour actualiser une patrie de mon page voila le code :
Code :
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php
include("fonction/connect.php"); 
if (isset($_GET['idr']))
{
	if (isset($_GET['action']) and ($_GET['action']=='ann'))
{
		$idd=$_GET['idr'];
		$f=$_GET['idrm'];
					//print "idreservastion ===".$idd."idrm====".$f ;
			mysql_query("UPDATE `f_reservation_detail` SET `valide`='N' WHERE (`idreservation` ='" . 		$idd ."' and `idrm` ='" . $f ."') LIMIT 1");	
//include("reloade.php");
//print "test1111111111111111";

print'<script type="text/javascript">';
print'valide2();</script>';   


}
	else{}

	$idr=$_GET['idr'];
	//print "n reservation :".$_GET['idr'];
	$sql = 'SELECT `f_client`.*, `f_reservation`.*, `f_reservation_detail`.*, `f_room`.*'
        . ' FROM f_client, f_reservation, f_room, f_reservation_detail'
        . ' WHERE ((`f_reservation`.`idreservation` ='.$idr.') AND(`f_reservation`.`idreservation` =`f_reservation_detail`.`idreservation`) AND (`f_client`.`idclient` =`f_reservation`.idclient) AND (`f_room`.`idrm` =`f_reservation_detail`.idrm))';
      
$d=mysql_fetch_array(mysql_query($sql));
?>
<table bgcolor="#A6B5B3" border="0" >
<tr>
	<td>
<table style="margin-right: 2px;margin-left: 10px;margin-bottom: 10px;" >
<tr><td>

<table id="table3" border="0" cellpadding="2" cellspacing="1" width="100%">

<tr>
            
                
<th width="92" align="left" bgcolor="#969696"    >
        <font face="Verdana"><span style="font-size: 9pt">Date arriv&eacute;e </span>
		</font>
    </th>
                
<th align="left" width="86" bgcolor="#969696"    >

        <font face="Verdana"><span style="font-size: 9pt">Date d&eacute;part </span>
		</font>
    </th> 
                
<th align="left" width="84" bgcolor="#969696"    >
        <span lang="fr"><font face="Verdana" style="font-size: 9pt">N</font></span><font face="Verdana"><span style="font-size: 9pt"><span lang="fr">ombre</span> nuit
		</span></font>
    </th>
                
<th align="left" width="95" bgcolor="#969696"    >
        <font face="Verdana"><span style="font-size: 9pt">Nombre
		adult</span></font></th>

                
<th align="left" bgcolor="#969696" width="105"    >
        <font face="Verdana"><span style="font-size: 9pt">Nombre
		enfant</span></font></th>
                
                
<th align="left" bgcolor="#969696"    >
        Prix</th>
                
</tr>
        
<tr >         
    <td align="right" valign="top"    bgcolor="#D5D5D5" class="nowrap" width="92">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['date_arrivee'];
?></span></font></td>
    <td valign="top"    bgcolor="#D5D5D5" nowrap="nowrap" width="86">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['date_depart'];
?></span></font></td>
    <td valign="top"    bgcolor="#D5D5D5" nowrap="nowrap" width="84"><?php
	print $d['date_depart'];
?></td>

    <td align="right" valign="top"    bgcolor="#D5D5D5" class="nowrap" width="95">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['date_depart'];
?></span></font></td>
    <td align="right" valign="top"    bgcolor="#D5D5D5" width="105"  >
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['date_depart'];
?></span></font></td>

    <td align="right" valign="top"    bgcolor="#D5D5D5"  >
	<?php
	print $d['date_depart'];
	$a12=$d['valide'];
	
?></td>

</tr>
            
</table>
    
    
<font face="Verdana"><span style="font-size: 9pt">
    
    
<!-- Results table -->
</span></font>
<table id="table4" border="0" cellpadding="2" cellspacing="1" width="100%">
<!-- Results table headers -->

<tr>
            
                
<th align="left" bgcolor="#969696"    >
        <p><font face="Verdana"><span style="font-size: 9pt">Nom
    </span></font>
    </th>
                
<th width="148" align="left" bgcolor="#969696"    >
        <font face="Verdana"><span style="font-size: 9pt">Pr&eacute;nom
    </span></font>
    </th>
                
<th width="265" align="left" bgcolor="#969696"    >
        <p><font face="Verdana"><span style="font-size: 9pt">Adresse
    </span></font>
    </th>
                
<th width="91" align="left" bgcolor="#969696"    >
        Ville</th>
                
<th width="95" align="left" bgcolor="#969696"    >
        <p><font face="Verdana"><span style="font-size: 9pt">T&eacute;l&eacute;phone</span></font></th>
                
<th width="264" align="left" bgcolor="#969696"    >

        <p><font face="Verdana"><span style="font-size: 9pt">E-mail</span></font></th>
                
</tr>
        
<!-- Results table body -->
    
<tr>         
    <td valign="top"    bgcolor="#D5D5D5">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['nom_client'];
?></span></font></td>

    <td valign="top"    bgcolor="#D5D5D5" width="148">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['prenom_client'];
?></span></font></td>
    <td valign="top"    bgcolor="#D5D5D5" width="265">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['adresse_client'];
?></span></font></td>
    <td valign="top"    bgcolor="#D5D5D5" width="91">
	<?php
	print $d['ville_client'];
?></td>
    <td valign="top"    bgcolor="#D5D5D5" width="95">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['tele_client'];
?></span></font></td>
    <td valign="top"    bgcolor="#D5D5D5" width="264">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $d['mail_client'];
?></span></font></td>

</tr>
            
</table>
<table id="table5" border="0" cellpadding="2" cellspacing="1" width="100%">

<tr>
            
<th width="205" align="left" bgcolor="#006400"    >
        <font face="Verdana" color="#FFFFFF"><span style="font-size: 9pt">Nom de chambre</span></font></th>
                
<th align="left" width="108" bgcolor="#006400"    >
        <font face="Verdana" style="font-size: 9pt" color="#FFFFFF">Nombre de lit
		</span></font>
    </th>
                
<th align="left" width="67" bgcolor="#006400"    >
        <font face="Verdana" color="#FFFFFF"><span style="font-size: 9pt">Max adult</span></font></th>

                
<th align="left" width="79" bgcolor="#006400"    >
        <font face="Verdana" color="#FFFFFF"><span style="font-size: 9pt">Max enfant
		</span></font></th>
                
<th align="left" width="69" bgcolor="#006400"    >
        <font face="Verdana" color="#FFFFFF"><span style="font-size: 9pt">Min adult
		</span></font></th>
                
<th align="left" width="79" bgcolor="#006400"    >
        <font face="Verdana" color="#FFFFFF"><span style="font-size: 9pt">Min enfant</span></font></th>
                
</tr>
     <?php
	$x=mysql_query($sql);
	while($dd=mysql_fetch_array($x))
	{
		
?>   
<tr  border="3">         
    <td valign="top"    bgcolor="#BEE9BE" width="205" height="23">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $dd['nomrm'];
?></span></font></td>

    <td align="right" valign="top"    bgcolor="#BEE9BE"   width="108" height="23">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $dd['nbr_lits'];
?></span></font></td>
    <td align="right" valign="top"    bgcolor="#BEE9BE"   width="67" height="23">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $dd['maxad'];
?></span></font></td>
    <td align="right" valign="top"    bgcolor="#BEE9BE"   width="79" height="23">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $dd['maxenf'];
?></span></font></td>
    <td align="right" valign="top"    bgcolor="#BEE9BE"   width="69" height="23">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $dd['minad'];
?></span></font></td>
    <td align="right" valign="top"    bgcolor="#BEE9BE"   width="79" height="23">
	<p align="left"><font face="Verdana"><span style="font-size: 9pt"><?php
	print $dd['minenf'];
?></span></font></td>

</tr>
<tr >
	<td align="right" bgcolor="#E1E1E1" colspan="2"></td><td align="right" bgcolor="#E1E1E1" colspan="1">
	<a style="cursor: pointer; color: red;" onclick="valide_reservation('<?php print $dd['idreservation'];?>','<?php print $dd['idrm'];?>','supp','1')">Supprimer</a>
	</td>
	<?php
	if($dd['valide']=='O')
	{
			$exp='detailreservation.php?action=ann&idr='.$dd['idreservation'].'&idrm='.$dd['idrm'];
			
?>
<td align="right" bgcolor="#E1E1E1" colspan="3" ><a style="cursor: pointer;"  onclick="Modalbox.show(this.title,'<?php print $exp ?>', {width: 631, afterLoad: function(){passValue('Current document')}}); return false;">Annuler la reservation</a>
<?php
	}
	else
	{
		$exp='detailreservation.php?idr='.$dd['idreservation'];
?>
<td align="right" bgcolor="#E1E1E1"><a onmousedown="valide_reservation('<?php print $dd['idreservation'];?>','<?php print $dd['idrm'];?>','valider');Modalbox.show(this.title, '<?php print $exp ?>', {width: 631, afterLoad: function(){ passValue('Current document') } }); return false;" onmouseup="valide2()" style="cursor: pointer;">Valider</a> 
<?php
	}

?>
</td>
</tr>
 <?php
print "zzz".$a12;
print'<input type="hidden" value="'.$a12.'" id="annuler">';
}
?>           
</table>
</td></tr>
</table>
</td>
</tr>
</table>
<?php
}else
{
	print "n reservation : ------ ";
}

?>
Merci.
red_nour est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h17.


 
 
 
 
Partenaires

Hébergement Web