Forum-webmaster
Technique - programmation => Javascript / DOM / Ajax => Message commencé par: mbells le le 03-05-2005 a 18:34:23

Titre: avec des requêtes SQL ?
Posté par: mbells le le 03-05-2005 a 18:34:23

Bonjour,
j'ai ce code pour faire afficher un menu déroulant.

Code:

bgcolor='#003366';
textcolor='#FF9933';
bgcolor2='#FF9933';
textcolor2='#003366';

document.write('<style type="text/css">');
document.write('.popper { POSITION: absolute; VISIBILITY: hidden; z-index:15; left:99px ')
document.write('#topgauche { position:absolute; z-index:10; }')
document.write('A:hover.ejsmenu {color:#000000; text-decoration:none;}')
document.write('.ejsmenu {color:#000000; text-decoration:none;}')
document.write('</style>')
document.write('<div style="position:relative;height:25"><DIV class=popper id=topdeck></DIV>');

zlien = new Array;
zlien[0] = new Array;
zlien[1] = new Array;
zlien[2] = new Array;
zlien[0][0] = 'Truc Muche';
zlien[0][1] = 'Bidule Chose';
zlien[1][0] = '<A HREF="lien2" CLASS=ejsmenu>Le 01/01/2006</A>';
zlien[2][0] = '<A HREF="lien2" CLASS=ejsmenu>Président</A>';
if(document.getElementById)
   {
   skn = document.getElementById("topdeck").style
   skn.left = 99;
   }

function pop(msg,pos)
{
skn.visibility = "hidden";
a=true
skn.top = pos;
var content ="<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#000000 WIDTH=100><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=1>";
pass = 0
while (pass < msg.length)
   {
   content += "<TR><TD BGCOLOR="+bgcolor+" style=\"color:#FF9933\" onMouseOver=\"this.style.background='"+bgcolor2+"';this.style.color='"+textcolor2+"'\" onMouseOut=\"this.style.background='"+bgcolor+"';this.style.color='"+textcolor+"'\" HEIGHT=20><FONT SIZE=1 FACE=\"Verdana\">&nbsp;&nbsp;"+msg[pass]+"</FONT></TD></TR>";
   pass++;
   }
content += "</TABLE></TD></TR></TABLE>";
document.getElementById("topdeck").innerHTML = content;
skn.visibility = "visible";
}
function kill()
{
   if(document.getElementById)
      skn.visibility = "hidden";
}
document.onclick = kill;
if(document.getElementById)
   {
   document.write('<DIV ID=topgauche><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#000000 WIDTH=100 HEIGHT=40><TR><TD><TABLE CELLPADING=0 CELLSPACING=1 BORDER=0 WIDTH=100% HEIGHT=60>')
document.write('<tr><TD WIDTH=100 ALIGN=center BGCOLOR='+bgcolor+' style="color:#FF9933" onMouseOver="this.style.background=\''+bgcolor2+'\';this.style.color=\''+textcolor2+'\';pop(zlien[0],0)" onMouseOut="this.style.background=\''+bgcolor+'\';this.style.color=\''+textcolor+'\'" CLASS=ejsmenu><FONT SIZE=1 FACE="Verdana">Partenaire</FONT></TD></tr>')
document.write('<tr><TD WIDTH=100 ALIGN=center BGCOLOR='+bgcolor+' style="color:#FF9933" onMouseOver="this.style.background=\''+bgcolor2+'\';this.style.color=\''+textcolor2+'\';pop(zlien[1],20)" onMouseOut="this.style.background=\''+bgcolor+'\';this.style.color=\''+textcolor+'\'" CLASS=ejsmenu><FONT SIZE=1 FACE="Verdana">Agenda</FONT></TD></tr>')
document.write('<tr><TD WIDTH=100 ALIGN=center BGCOLOR='+bgcolor+' style="color:#FF9933" onMouseOver="this.style.background=\''+bgcolor2+'\';this.style.color=\''+textcolor2+'\';pop(zlien[2],40)" onMouseOut="this.style.background=\''+bgcolor+'\';this.style.color=\''+textcolor+'\'" CLASS=ejsmenu><FONT SIZE=1 FACE="Verdana">Trombinoscope</FONT></TD></tr>')
   document.write('</TABLE></TD></TR></TABLE></DIV>')
   }
document.write('</div>');

J'aimerai savoir si il est possible de remplacer :

Code:

zlien[0][0] = 'Truc Muche';
zlien[0][1] = 'Bidule Chose';

par des éléments d'une base de donnée et le faire dans le style :

Code:

resulat="select non, prenom from mesPotes;";
nbr="select count(*) from mesPotes;";
for(i=0;i<nbr;i++)
zlien[0]=resultat[0]." ".resultat[1];


Titre: Re:avec des requêtes SQL ?
Posté par: nyrodev le le 03-05-2005 a 18:50:11

Ben avant de demander, tu aurai peut-être pu tester...
Donc oui, c'est tout à fait possible, suffit juste de génrer le bon code JavaScripit qui ira pour ton script.
Pense aussi à générer les liens qui vont avec dynamiquement...
Enfin je pense que tu auras besoin de faire ca, sinon, ca n'aurai aucun intéret


Forum-webmaster | Actionné par YaBB SE
© 2001-2003, YaBB SE Dev Team. Tous droits réservés.