🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.text.xml
Article #9725

XSL et Javascript..

#9725
From: HERVE LEDOUX
Date: Sun, 11 Feb 2001 11:12
51 lines
2812 bytes
Bonjour, je debute un peu en Xml et j'ai un gros probleme!!
Lors d'un clic sur un bouton, je voudrais afficher un <DIV> .
Cela marche tres bien, mais je n'arrive pas a automatiser quand je suis dans
une boucle "for-each".


J'utilise du javascript dans ma feuille XSL


Dans mon fichier XML, j'ai 4 <question numero="xxx"> xxx=1,2,3 ou 4.
Dans mon XSL, chaque question est � l'interieur d'un <DIV> et un bouton est
cr�e � chaque fois. Le premier <DIV> avec son bouton est visible et les
autrezs sont cach�s (hidden).
Quand je clique sur un bouton appartenant � un <DIV>, je voudrais afficher
le <DIV> suivant. ( le rendre visible)

voila un script qui fonctionne a peu pres..

<script language="javascript">
function
afficher(nom){document.getElementById(nom).style.visibility="visible";}
</script>
.....
...
<xsl:for-each select="question">
<xsl:element name="div"><xsl:attribute name="id">div<xsl:value-of
select="@numero"/></xsl:attribute>
<xsl:attribute name="style">visibility:<xsl:value-of
select="@etat"/></xsl:attribute>
<script>vat temp='<xsl:value-of select="@numero"/>';
document.write('<INPUT TYPE="button" VALUE="Exercice suivant"
onclick="affiche(temp)" />');
document.write('<INPUT TYPE="button" VALUE="Recommencer exercice"/>');}
</script>
</xsl:element>
</xsl:for-each>

Le probleme :
Quand je clique sur le bouton c'est toujours le 4eme <div> qui s'affiche.
 donc pas le suivant comme je le voudrais)
En fait je crois que la variable 'temp' vaut 4 � la fin de la generation en
HTML (le numero de la derniere question).

J'avais penser � ne pas utiliser de variable mais de passer directement en
parametre la valeur de l'attribut :
document.write('<INPUT TYPE="button" VALUE="Exercice suivant"
onclick="affiche(<xsl:value-of select="@numero"/>)" />');
Mais ca marche pas..

Besoin d'aide
Merci.
Technical Details
Message-ID: <dsuh6.1703$ll5.3516456@nnrp5.proxad.net>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!193.251.151.101!opentransit.net!proxad.net!feeder2.proxad.net!nnrp5.proxad.net.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII
X-Google-Thread: 114f60,ce657c355662f383,start
X-Google-Attributes: gid114f60,public
X-Google-ArrivalTime: 2001-02-11 03:13:23 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!193.251.151.101!opentransit.net!proxad.net!feeder2.proxad.net!nnrp5.proxad.net.POSTED!not-for-mail
From: "HERVE LEDOUX" <hledoux@free.fr>
Newsgroups: fr.comp.text.xml
Subject: XSL et Javascript..
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Message-ID: <dsuh6.1703$ll5.3516456@nnrp5.proxad.net>
Date: Sun, 11 Feb 2001 11:12:09 GMT
NNTP-Posting-Host: 213.228.27.136
X-Complaints-To: abuse@proxad.net
X-Trace: nnrp5.proxad.net 981889929 213.228.27.136 (Sun, 11 Feb 2001 12:12:09 CET)
NNTP-Posting-Date: Sun, 11 Feb 2001 12:12:09 CET
Organization: Guest of ProXad - France