[JAVA] commenter des photos qui défilent

Résolu/Fermé
babili Messages postés 27 Date d'inscription vendredi 1 août 2008 Statut Membre Dernière intervention 3 octobre 2010 - 19 nov. 2009 à 21:44
babili Messages postés 27 Date d'inscription vendredi 1 août 2008 Statut Membre Dernière intervention 3 octobre 2010 - 22 nov. 2009 à 11:44
Bonjour,

Voila j'ai trouver un script bien fait pour avoir une visionneuse d'image, cela marche très bien et je voudrait grâce a la variable "numero" pouvoir afficher un commentaire qui changerai quand on change de photo. le script de visionneuse est interne et je voudrait que le script des commentaire soit externe. (vous comprendrez mieux en regardant, voila)

 < head >
                        ...
                        <script language="JavaScript">
<!--
//PLF-https://twitter.com/ceosammassey
var bauto = 0;
var dossier="../images/";
var numero = 1;
function objet() {
this.length = objet.arguments.length
for (var i = 0; i < this.length; i++) this[i+1] = objet.arguments[i]
}
var nom = new objet ("a1.jpg", "a2.jpg", "a3.jpg");
function suivante() {
numero += 1;
if (numero == nom.length + 1) numero = 1;
document.image.src = dossier+nom[numero];
}
function precedente() {
numero -= 1;
if (numero == 0) numero = nom.length; 
document.image.src = dossier+nom[numero];
}
function changer() {
numero += 1;
if (numero == nom.length + 1) numero = 1;
document.image.src = dossier+nom[numero];
roll=setTimeout("changer()", 1500);
}
function initial() {
window.clearTimeout(roll);
document.image.src = dossier+nom[numero];
}
function auto() {
if (bauto == 0) {
bauto =1; changer();
document.vision.automat.value=" Lect/Stop "; 
} 
else {
bauto =0; initial();
document.vision.automat.value=" Lect/Auto ";
}
}
//-->
</script>
</head>
<body> 
           <div class="corps">
<h1>Photos</h1>
<hr/>
	<form name="vision">
<div align="center"> 
<input type="button" name="precedent" value="Précédente" onClick="precedente();"> 
<input type="button" name="suivant" value=" Suivante " onClick="suivante();">
<input type="button" name="automat" value=" Lect/Auto "onClick="auto();">
</div>
</form>
<div align="center"><img src="../images/a1.jpg" name="image"></div>
<h2>Commentaire</h2>
<hr/>
<div class="commentaire" align="center" >
<script language="javascript" type="text/javascript" src="../js/commentaires.js"></script></div>
	</div>
</body>


voila pour la page html, et j'avais pensé faire un script comme ceci pour généré mes commentaires:

<!--
//c.philippe !! commentaire des photo en fonction de la variable numero
var com0 = "Commentaire des différentes photo";
var com1 = "Un planchiste en plien Jibe"
var com2 = "Une ancienne planche à voile, plus éfilé."
var com3 = "Planche à voile des année 1970"
//...
//var comN =  commentaire pour N photo
function Write() {
if (numero == 1) window.document.write("com1");
if (numero == 2) window.document.write("com2");
if (numero == 3) window.document.write("com3");
//...
// if (numero == N) window.document.write("comN")
else window.document.write("com0")
!-->


Bon mon problème et que je comprend un peu le js mais je le maitrise surement pas. j'aimerai avoir vos correction ou vos proposition pour satisfaire ma requete.

merci pour votre aide.
A voir également:

2 réponses

Utilisateur anonyme
20 nov. 2009 à 16:08
pas trés bonne ta solution
il vaut mieux ecrire window.document.write("com"+numero) plutot qu une serie de if
si t as 400 photos ...
0
babili Messages postés 27 Date d'inscription vendredi 1 août 2008 Statut Membre Dernière intervention 3 octobre 2010
22 nov. 2009 à 11:44
voila j'ai trouvé une solution qui marche bien :

var q;
var com1 = "Un planchiste en plein Jibe";
var com2 = "Une ancienne planche à voile, plus éfilé.";
var com3 = "Planche à voile des année 1970";
function com() {
if (numero == 1) q = com1;
else if (numero == 2) q = com2;
else if (numero == 3) q = com3;
document.getElementById('com').innerHTML=q;
}


j'ai rajouter ce code avant le script et inclut la fonction com() dans suivant() precedent() changer(). et ça marche (je te rassure il n'y aura qu'une 20ene de photo.
0