Probleme php - formulaire - area shape

Fermé
pomy - 18 déc. 2003 à 00:28
 pomy - 18 déc. 2003 à 10:53
Bonjour à tous,
J'ai un ptit problème, je voudrais faire un submit de ma form en utilisant une image mapée qui renvera des valeur différentes en fonction des différente area sur ma map. Comment faire pour que à chaques area de la map je puisse faire le submit et envoyer une valeur différente

J'ai bien éssayer de le faire avec un onclick qui renvoie vers une fonction javascript qui utilise form.submit(), mais ca marche pas . Au secour, je trouve pas

1 réponse

voici qd mleme le code

<html>

<head>
<title>Easyalgo</title>

<SCRIPT LANGUAGE="JavaScript">
function ENVOYERFORM(pos,opt)
{
test.position.value=pos;
test.option.value=opt;
test.submit();
return;
}
</SCRIPT>
</head>


<body BACKGROUND="puzb.gif">
<center>
<table width='400' BGCOLOR="#A3C6D5">
<tr><td><center><H1><FONT COLOR="#2E9897">Créez vous même votre structure algorithmique</FONT></H1></center></td></tr>
</table>
</center>
<br><br><br><br><br>

<?
$connect = mysql_connect('localhost', 'root', '');
$result=mysql_select_db('easyalgo');
$queryresult=mysql_query('delete from algo');
$queryresult=mysql_query("insert into algo (position,taille,type,coorddebut,coordfin) values (0,70,'ddebut',0,70)");
$queryresult=mysql_query("insert into algo (position,taille,type,coorddebut,coordfin) values (1,70,'drectangle',70,140)");
$queryresult=mysql_query("insert into algo (position,taille,type,coorddebut,coordfin) values (2,70,'drectangle',140,210)");
$queryresult=mysql_query("insert into algo (position,taille,type,coorddebut,coordfin) values (3,70,'dfin',210,280)") ;

function ddebut($y,$canva) {
$cbalise = ImageColorAllocate($canva, 17, 112, 255);
$bleu = ImageColorAllocate($canva, 0, 0, 255);
imagefilledpolygon($canva,array(90,20+$y,90,40+$y,100,50+$y,160,50+$y,170,40+$y,170,20+$y, $rouge),6,$cbalise);
imageline($canva,130, 50+$y, 130, 70+$y, $bleu);
Imagejpeg($canva,'canva.jpg');


}

function dfin($y,$canva) {
$cbalise = ImageColorAllocate($canva, 17, 112, 255);
$bleu = ImageColorAllocate($canva, 0, 0, 255);
imagefilledpolygon($canva,array(100,20+$y,90,30+$y,90,50+$y,170,50+$y,170,30+$y,160,20+$y, $rouge),6,$cbalise);
imageline($canva,130, 0+$y, 130, 20+$y, $bleu);
Imagejpeg($canva,'canva.jpg');

}


function drectangle($y,$canva) {
$rouge = ImageColorAllocate($canva, 251, 97, 77);
$bleu = ImageColorAllocate($canva, 0, 0, 255);
imagefilledrectangle($canva,90, 20+$y, 170, 50+$y, $rouge);
imageline($canva,130, 0+$y, 130, 20+$y, $bleu);
imageline($canva,130, 50+$y, 130, 70+$y, $bleu);
$sqlquery ="select * from algo where type='drectangle'" ;
$queryresult=mysql_query($sqlquery);
$tabcheck=mysql_fetch_array($queryresult);


}


function dessintable() {

//dessin de toute la table
//compte le nb de lignes
$sqlquery ="select * from algo";
$queryresult=mysql_query($sqlquery);
$nombreligne = mysql_num_rows($queryresult);
// boucle dessin
$flenth=0;
for ($i=0;$i<$nombreligne;$i++)
{
$sqlquery ="select * from algo where position='".$i."'" ;
$queryresult=mysql_query($sqlquery);
$tabcheck=mysql_fetch_array($queryresult);
$Flenth+=$tabcheck['taille'];
}
$canva = imagecreate(260,$Flenth);
$blanc = ImageColorAllocate($canva, 255, 255, 255);
imagefill($canva,0,0,$blanc);

for ($i=0;$i<$nombreligne;$i++)
{
$sqlquery ="select * from algo where position='".$i."'" ;
$queryresult=mysql_query($sqlquery);
$tabcheck=mysql_fetch_array($queryresult);
$tabcheck['type'] ($tabcheck['coorddebut'],$canva);
}
// dessin des numeros
$noir = ImageColorAllocate($canva, 0, 0, 0);
$sqlquery ="select * from algo";
$queryresult=mysql_query($sqlquery);
$nombreligne = mysql_num_rows($queryresult);
for ($i=0;$i<$nombreligne-1;$i++){
$sqlquery ="select * from algo where position='".$i."'" ;
$queryresult=mysql_query($sqlquery);
$tabcheck=mysql_fetch_array($queryresult);
switch ($tabcheck['type']){
case "drectangle" or "ddebut" or "dfin" or "ddountil":
$pos=$tabcheck['coorddebut']+30;
imagestring($canva, 5, 127, $pos,$tabcheck['position'], $noir);
break;
case "dif" or "difthenelse" or "dwhile":
$pos=$tabcheck['coorddebut']+55;
imagestring($canva, 5, 127, $pos, $tabcheck['position'], $noir);
break;

}

}
Imagejpeg($canva,'canva.jpg');
echo "<img src='canva.jpg' usemap='#map'>";
}






echo "<center>";
echo"<table width='800' border='0'>";
echo"<tr><td width='400'>";


$sqlquery ="select * from algo";
$queryresult=mysql_query($sqlquery);
$nombreligne = mysql_num_rows($queryresult);
for ($i=0;$i<$nombreligne;$i++)
{
$sqlquery ="select * from algo where position='".$i."'" ;
$queryresult=mysql_query($sqlquery);
$tabcheck=mysql_fetch_array($queryresult);

$tabsave['pos'][$i]=$tabcheck['position'];
$tabsave['coordd'][$i]=$tabcheck['coorddebut'];
$tabsave['coorf'][$i]=$tabcheck['coordfin'];
$tabsave['type'][$i]=$tabcheck['type'];
$cpt++;

}




echo"<map name='map'>";

for ($i=0;$i<$cpt;$i++){
echo" <area shape='rect' coords='0,".$tabsave['coordd'][$i].",260,".$tabsave['coorf'][$i]."' onClick='ENVOYERFORM(".$tabsave['pos'][$i].",".$tabsave['type'][$i].");'/>";
}
echo "</map>";

dessintable();
echo"</td><td>";
echo "<table align='center' cellpadding='3' border='1'>";
echo "<tr><td colspan='2'><center><b>Que voulez vous inserer?</b></center></td></td>";
echo "<form name='test' method='get' action='dessin.php'>";
echo "<tr><td colspan='2'><input type='radio' name='option' />rectangle</td></td>";
echo "<tr><td colspan='2'><input type='radio' name='option' />If</td></td>";
echo "<tr><td colspan='2'><input type='radio' name='option' />If then else</td></td>";
echo "<tr><td colspan='2'><input type='radio' name='option' />Boucle While</td></td>";
echo "<tr><td colspan='2'><input type='radio' name='option' />Boucle Until</td></td>";

echo "</center>";
echo "<tr><td colspan='2'><div align='center'>";
echo "<input type='hidden' name='position'/>";

echo "</div>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
echo"</td></tr>";
echo "</center>";


?>







</body>

</html>
2