Partage
  • Partager sur Facebook
  • Partager sur Twitter

Menu slide

javascript

    14 décembre 2010 à 19:13:58

    Bonjour,

    Je suis en train de creer un petit menu slide, et j'aimerai mettre du text a la place
    d'une image. ci-dessous, j'ai essayé de le faire, mais ca fonctionne que avec les images...
    A cause du src=.
    Avez vous une idee ? Pouvez vous m'aider ?

    Je suis débutant en JS...

    Comme vous pouvez le voir ci dessous, j'ai essayé avec un label et un getElementById(),
    mais ca ne marche pas.

    D'avance, je vous remercie pour votre aide et vous dis a bientot.

    cretthie

    <script language="JavaScript">
     var myPix = new Array( "<a href=\"http://www.google.ch\"><img src=\"img1.gif\"></a>","img2.gif","img3.gif","img4.gif","img5.gif","img6.gif");
     "<a href=\"http://www.google.ch\"><img src=\"img1.gif\"></a>"
     var pic1 = 0;
     var pic2 = 1;
     var pic3 = 2;
     var longueur=myPix.length;
    
     function doPrevious() 
    	 {
    		 if (document.images && pic1 > 0) 
    		{
    			pic1--;
    			document.getElementById('myPicture1').value = myPix[pic1];
    		}
    		 if (document.images && pic2 > 0+1) 
    		{
    			pic2--;
    			document.myPicture2.src=myPix[pic2];
    		}
    		 if (document.images && pic3 > 0+2) 
    		{
    			pic3--;
    			document.myPicture3.src=myPix[pic3];
    		}
    	 }
    
     function doNext() 
    	{
    		if (document.images && pic1 < myPix.length-3) 
    		{
    			pic1++;
    			document.myPicture1.src=myPix[pic1];
    		}
    		if (document.images && pic2 < myPix.length-2) 
    		{
    			pic2++;
    			document.myPicture2.src=myPix[pic2];
    		}
    		if (document.images && pic3 < myPix.length-1) 
    		{
    			pic3++;
    			document.myPicture3.src=myPix[pic3];
    		}
    	}
     </script>
      
     <table align="center">
     <tr>
    	<td>
    	<input type="image" name="precedent" src="precedent.gif" onclick="javascript:doPrevious()">
    	</td>
    	<td>
    		<label id="myPicture1" width="100" height="57" value="<a href='http://www.google.ch'><img src='img1.gif'></a>"></label>
    	</td>
    	<td>
    		<img name="myPicture2" src="img2.gif" width="100" height="57">
    	</td>
    	<td>
    		<img name="myPicture3" src="img3.gif" width="100" height="57">
    	</td>
    	<td>
    	<input type="image" name="suivant" src="suivant.gif" onclick="javascript:doNext()">
    	</td>
     </tr>
    </table>
    
    • Partager sur Facebook
    • Partager sur Twitter

    Menu slide

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown