if ($mat <> '') {...}
il faut quand même que tu rajoutes la valeur de l'id récupérée non ? if($mat!="" && $mat==ton_id) {} non ?
if ($mat <> '') {...}
il faut quand même que tu rajoutes la valeur de l'id récupérée non ? if($mat!="" && $mat==ton_id) {} non ?$mat=document.enreg.perso.value;
Code : Tout sélectionner
function ChangeValeur(formulaire) {
$mat=document.enreg.perso.value;
}document.enreg.perso.value;
dans une variable ?
function Changevaleur(formulaire)
{
var mat =document.enreg.perso.value;
window.location.href = "nomdetapage.php?mat="+mat;
}
Comme sa apres tu peut le recupe avec dans un $request['mat']
Code : Tout sélectionner
function Changevaleur() // l'attribut n'est pas utilisé, alors pourquoi le garder ? :)
{
// certains navigateur n'acceptent pas l'accès direct au value d'un select il vaut donc mieux suivre le dom pour préciser que l'on veut la valeur de l'option choisie :
var mat = document.enreg.perso.options[document.enreg.perso.selectedIndex].value;
window.location.href = "nomdetapage.php?mat="+mat;
} Code : Tout sélectionner
<select ... onChange="window.location.href = 'nomdetapage.php?mat=' + this.options[this.selectedIndex].value;">
Code : Tout sélectionner
<select ... onChange="document.location='nomdetapage.php?mat=' + this.options[this.selectedIndex].value;"><html>
<head>
<title>Les grands comptes</title>
<script language="javascript">
function choisir(truc, truc2, truc3, truc4)
{
window.opener.document.enreg.mat.value= truc;
window.opener.document.enreg.gc.value= truc2;
self.close();}
function Changevaleur() // l'attribut n'est pas utilisé, alors pourquoi le garder ? :)
{
// certains navigateur n'acceptent pas l'accès direct au value d'un select il vaut donc mieux suivre le dom pour préciser que l'on veut la valeur de l'option choisie :
var matgc = document.enreg.grcpt.options[document.enreg.grcpt.selectedIndex].value;
window.location.href = "grcpt2.php?matgc="+matgc;
}
</script>
<style type="text/css">
<!--
.Style1 {font-family: Tahoma}
-->
</style>
</head>
<body>
<span class="Style1">
<?php
include_once("connexion.php");
?>
</span>
<p align="left" class="Style1"> </p>
<form name="enreg" method="post" action="">
<?php
$Req = mysql_query("SELECT nom_gc, matricule_gc FROM grand_compte where nom_gc<>''ORDER BY nom_gc");
$ld = "<SELECT NAME='grcpt' onChange='document.location='grcpt2.php?matgc=' + this.options[this.selectedIndex].value;'>";
$ld .= "<OPTION VALUE=0>Choisissez</OPTION>";
// On boucle sur la table
while ( $row = mysql_fetch_array($Req)) {
$nom = $row["nom_gc"];
$mat = $row["matricule_gc"];
$ld .= "<OPTION VALUE='$mat'>$nom</OPTION>";
}
$ld .= "</SELECT>";
?>
<?php
print $ld;;
if(isset($_GET['matgc']))
{$matgc=$_GET['matgc'];
}
?>
</form>
<?php
if ($matgc <> '') { ?>
<p align="left" class="Style1"> </p>
<p class="Style1"></p>
<p class="Style1"></p>
<table width="100%" border="1">
<tr align="center" valign="middle">
<td width="9%" class="Style1">Matricule du site </td>
<td width="17%" class="Style1">Adresse</td>
<td width="6%" class="Style1">Code postal </td>
<td width="21%" class="Style1">Ville</td>
</tr>
<?php
// on crée la requête SQL
$reqsql2 = mysql_query("SELECT `lieux`.`matricule_lieux`, `lieux`.`ad_rue_lieux`, `cp_ville`, `ville`, `nom_gc`, lieux.site
from `lieux`, `ville`, `grand_compte`
where `grand_compte`.`matricule_gc`=`lieux`.`matricule_gc`
and `lieux`.`code_ville`=`ville`.`code_ville`
and `lieux`.`matricule_gc`='$grcpt' order by `ville`");
while ($rep = @mysql_fetch_object($reqsql2)) {
$mat = $rep->matricule_lieux;
$ad = $rep->ad_rue_lieux;
$cp = $rep->cp_ville;
$vil = $rep->ville;
$gc = $rep->nom_gc;
$sit= $rep->site;
?>
<tr align="center" valign="middle">
<td class="Style1"><a href="#" onClick="javascript:choisir('<?php echo $mat; ?>' , '<?php echo $gc; ?>' , '<?php echo $ad." ".$cp." ".$vil ?>', '<?php echo $sit; ?>' )" ><?php echo $mat; ?></a></td>
<td class="Style1"><?php echo $ad ?></td>
<td class="Style1"><?php echo $cp ?></td>
<td class="Style1"><?php echo $vil ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
<div align="center" class="Style1"></div>
</body>
</html>
j'ai changé quelque trucs sans importance.<p align="left" class="Style1"> </p>
....
$ld = "<SELECT NAME='grcpt' onChange='document.location.href='grcpt2.php?matgc=' + this.options[this.selectedIndex].value;'>";
...
Mais avec ça tu réinvente un submit pour rien. tu peux déclencher le submit par onChange sans demander un chargement par "location.href" puisque t'as un formulaire.<form name="enreg" method="post" >
<?php
....
....
$ld = "<SELECT NAME='grcpt' onChange='enreg.submit();'>";
....
....
$ld = "<SELECT NAME='grcpt' onChange=\"document.location.href='grcpt2.php?matgc=' + this.options[this.selectedIndex].value;\">";
Pour la 2e sa:
<form name="enreg" action="grcpt2.php" method="post" >
Mais je me trompe peut etre!