Bonjour ou bonsoir voila j'ai mon code javascript de mon menu. et je bug sur l'insertion de mes tables dans le script( je suis débutant)
voilà le script si une bonne ame peut me donner un petit coup de main:
<html>
<head>
<script language="JavaScript" TYPE="text/javascript">
function swap(x) {
document.getElementById("stage").innerHTML = "<img src='images/" + x + "' border='0'>";
}
</script>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Sans titre</title>
<meta name="generator" content="Namo WebEditor v4.0">
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<form method="post" action="index.php" name="SearchWidget">
<input TYPE="HIDDEN" NAME="Action" VALUE="1">
<input TYPE="HIDDEN" NAME="search" VALUE="1">
<table width="142" cellpadding="0" cellspacing="0" border="0"><tr><td bgcolor="#DFE3EE" nowrap ALIGN="center" height="20"><select name="categorysearch" size="1" onChange="redirect(this.options.selectedIndex)" class="fill">
<option selected value="0">----- Category -----</option>
<?php
$sql = @mysql_connect("localhost", "root", "")
or die("Connexion down");
@mysql_select_db("test", $sql)
or die("DB Down");
$requete = mysql_query("SELECT * from automenu")
or die("Requete down");
while ($r = mysql_fetch_array($requete) )
{
echo "<option value=$r[id]>$r[categorie]</option>";
}
?>
</select></td>
<tr><td bgcolor="#DFE3EE" nowrap ALIGN="center"><select name="makesearch" size="1" onChange="redirect1(this.options.selectedIndex)" class="fill">
<option value="0" selected>------- Make -------</option><?php
$sql = @mysql_connect("localhost", "root", "")
or die("Connexion down");
@mysql_select_db("test", $sql)
or die("DB Down");
$requete = mysql_query("SELECT * from automarq")
or die("Requete down");
while ($r = mysql_fetch_array($requete) )
{
echo "<option value=$r[idcat]>$r[marq]</option>";
}
?></select></td></tr>
<tr><td bgcolor="#DFE3EE" nowrap ALIGN="center"><select name="modelsearch" size="1" class="fill">
<option value=" " selected>------- Model ------</option><?php
$sql = @mysql_connect("localhost", "root", "")
or die("Connexion down");
@mysql_select_db("test", $sql)
or die("DB Down");
$requete = mysql_query("SELECT * from automod")
or die("Requete down");
while ($r = mysql_fetch_array($requete) )
{
echo "<option value=$r[idmarq]>$r[mod]</option>";
}
?></select></td></tr>
<tr><td bgcolor="#DFE3EE" nowrap ALIGN="center">
<select name="pricesearch" size="1" CLASS="fill">
<option value="0" >- Maximum Price -</option>
</select>
</td></tr>
<tr><td bgcolor="#DFE3EE" background="images/spacer.gif" nowrap ALIGN="CENTER" HEIGHT="25" VALIGN="MIDDLE"><input type="submit" value="Search" CLASS="fillb"></td></tr>
</table>
<script language="JavaScript" TYPE="text/javascript">
<!--
document.SearchWidget.makesearch.disabled = true
document.SearchWidget.modelsearch.disabled = true
document.SearchWidget.pricesearch.disabled = true
var groups=document.SearchWidget.categorysearch.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
group[0][0]=new Option("------- Make -------","0");
var temp=document.SearchWidget.makesearch
function redirect(x){
for (m=temp.options.length-1;m>0;m--) {
temp.options[m]=null
}
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
redirect1(0)
if (document.SearchWidget.categorysearch.value == "0") {
document.SearchWidget.makesearch.disabled = true
document.SearchWidget.modelsearch.disabled = true
document.SearchWidget.pricesearch.disabled = true
} else {
document.SearchWidget.makesearch.disabled = false
document.SearchWidget.modelsearch.disabled = true
document.SearchWidget.pricesearch.disabled = false
}
}
var secondGroups=document.SearchWidget.makesearch.options.length
var secondGroup=new Array(groups)
for (i=0; i<groups; i++) {
secondGroup[i]=new Array(group[i].length)
for (j=0; j<group[i].length; j++) {
secondGroup[i][j]=new Array()
}
}
secondGroup[0][0][0]=new Option("------- Model ------","0");
var temp1=document.SearchWidget.modelsearch
function redirect1(y) {
for (m=temp1.options.length-1;m>0;m--) {
temp1.options[m]=null
}
for (i=0;i<secondGroup[document.SearchWidget.categorysearch.options.selectedIndex][y].length;i++) {
temp1.options[i]=new Option(secondGroup[document.SearchWidget.categorysearch.options.selectedIndex][y][i].text,secondGroup[document.SearchWidget.categorysearch.options.selectedIndex][y][i].value)
}
temp1.options[0].selected=true
if ( document.SearchWidget.makesearch.value == "0") {
document.SearchWidget.modelsearch.disabled = true
} else {
document.SearchWidget.modelsearch.disabled = false
}
}
//-->
</form>
</script>
</body>
</html>