Rechercher : dans
Par :

Evenement onclick ^^

Dernière réponse le 25 fév 2009 à 14:00:20 cheese42, le 25 fév 2009 à 02:21:01 
 Signaler ce message aux modérateurs

Bonjour,
voila, je voudrais savoir si vous connaissez un tuto ou bien si vous en savez un peu plus que moi sur le onclick, ce que je voudrais c'est comment sur une petite image, si on clique dessus,
<a href="#pagedemonsite" onclick=""><img src="1.gif" name="n1" alt="1" width="30" height="30" id="n1" /></a>, ca c'est mon code, je voudrais que le numero1 ecrit dans l'image vienne se mettre dans ceci ::
<input type="text" name="x1" size="2">
Vous comprenez ce que je veux dire, c'est que en cliquant sur l'image, ben ca m'affiche dans le input le no cliqué^^attention,il y a 50 numeros differents^^que si on clic sur le exemple42, bah ca affiche le chiffre 42 dans le input , voila^^, merci a tous ceux qui m'aideront un peu !!

----------------------------------------------------------------------
/  La vie ne vaut rien mais rien ne vaut la vie !!!!!  /
----------------------------------------------------------------------

Configuration: Windows XP
Firefox 3.0.6

1

gaerebut, le 25 fév 2009 à 03:42:18

<img src="1.gif" name="1" alt="1" width="30" height="30" id="1" onclick="document.getElementById('x1').innerHTML = this.id" style="cursor: pointer"/>

<img src="2.gif" name="2" alt="2" width="30" height="30" id="2" onclick="document.getElementById('x1').innerHTML = this.id" style="cursor: pointer"/>

<input type="text" name="x1" size="2"> 


A+

Gaerebut Il y a 2 règles d'or pour réussir dans la vie :
-Règle 1:  ne jamais dire tout ce que l'on sait...
-Règle 2: ...

Répondre à gaerebut

2

cheese42, le 25 fév 2009 à 04:00:41

Merci^^, j'essaie cela de suite et je te dis^^ ------------------------------------------------------------­----------
/  La vie ne vaut rien mais rien ne vaut la vie !!!!!  /
------------------------------------------------------------­----------

Répondre à cheese42

3

cheese42, le 25 fév 2009 à 04:07:54

C'est bizarre ton code devrait marcher moi il marche pas -_- ........... ------------------------------------------------------------­----------
/  La vie ne vaut rien mais rien ne vaut la vie !!!!!  /
------------------------------------------------------------­----------

Répondre à cheese42

4

gaerebut, le 25 fév 2009 à 13:46:14

Salut,

oui normal, t'as pas mis d'ID à ton champ texte et je me suis trompé c'est pas innerHTML mais value.

document.getElementByName('x1').value= this.id


Tu peux mettre getElementById si tu met un id dans ton champ texte !

A+

Gaerebut Il y a 2 règles d'or pour réussir dans la vie :
-Règle 1:  ne jamais dire tout ce que l'on sait...
-Règle 2: ...

Répondre à gaerebut

5

cheese42, le 25 fév 2009 à 13:58:10

Bon, je te mets le code de ma page, moi je comprends pas^^

<table width="300" border="3" cellspacing="0">
<tr>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b1.gif" name="n1" alt="1" width="30" height="30" id="1" onclick="document.getElementById('x1').innerHTML = this.id" style="cursor: pointer"/></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b2.gif" name="n2" alt="2" width="30" height="30" id="n2" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b3.gif" name="n3" alt="3" width="30" height="30" id="n3" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b4.gif" name="n4" alt="4" width="30" height="30" id="n4" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b5.gif" name="n5" alt="5" width="30" height="30" id="n5" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b6.gif" name="n6" alt="6" width="30" height="30" id="n6" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b7.gif" name="n7" alt="7" width="30" height="30" id="n7" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b8.gif" name="n8" alt="8" width="30" height="30" id="n8" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b9.gif" name="n9" alt="9" width="30" height="30" id="n9" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b10.gif" name="n10" alt="10" width="30" height="30" id="n10" /></a></td>
</tr>
<tr>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b11.gif" name="n11" alt="11" width="30" height="30" id="n11" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b12.gif" name="n12" alt="12" width="30" height="30" id="n12" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b13.gif" name="n13" alt="13" width="30" height="30" id="n13" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b14.gif" name="n14" alt="14" width="30" height="30" id="n14" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b15.gif" name="n15" alt="15" width="30" height="30" id="n15" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b16.gif" name="n16" alt="16" width="30" height="30" id="n16" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b17.gif" name="n17" alt="17" width="30" height="30" id="n17" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b18.gif" name="n18" alt="18" width="30" height="30" id="n18" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b19.gif" name="n19" alt="19" width="30" height="30" id="n19" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b20.gif" name="n20" alt="20" width="30" height="30" id="n20" /></a></td>
</tr>
<tr>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b21.gif" name="n21" alt="21" width="30" height="30" id="n21" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b22.gif" name="n22" alt="22" width="30" height="30" id="n22" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b23.gif" name="n23" alt="23" width="30" height="30" id="n23" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b24.gif" name="n24" alt="24" width="30" height="30" id="n24" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b25.gif" name="n25" alt="25" width="30" height="30" id="n25" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b26.gif" name="n26" alt="26" width="30" height="30" id="n26" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b27.gif" name="n27" alt="27" width="30" height="30" id="n27" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b28.gif" name="n28" alt="28" width="30" height="30" id="n28" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b29.gif" name="n29" alt="29" width="30" height="30" id="n29" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b30.gif" name="n30" alt="30" width="30" height="30" id="n30" /></a></td>
</tr>
<tr>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b31.gif" name="n31" alt="31" width="30" height="30" id="n31" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b32.gif" name="n32" alt="32" width="30" height="30" id="n32" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b33.gif" name="n33" alt="33" width="30" height="30" id="n33" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b34.gif" name="n34" alt="34" width="30" height="30" id="n34" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b35.gif" name="n35" alt="35" width="30" height="30" id="n35" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b36.gif" name="n36" alt="36" width="30" height="30" id="n36" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b37.gif" name="n37" alt="37" width="30" height="30" id="n37" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b38.gif" name="n38" alt="38" width="30" height="30" id="n38" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b39.gif" name="n39" alt="39" width="30" height="30" id="n39" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b40.gif" name="n40" alt="40" width="30" height="30" id="n40" /></a></td>
</tr>
<tr>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b41.gif" name="n41" alt="41" width="30" height="30" id="n41" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b42.gif" name="n42" alt="42" width="30" height="30" id="n42" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b43.gif" name="n43" alt="43" width="30" height="30" id="n43" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b44.gif" name="n44" alt="44" width="30" height="30" id="n44" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b45.gif" name="n45" alt="45" width="30" height="30" id="n45" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b46.gif" name="n46" alt="46" width="30" height="30" id="n46" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b47.gif" name="n47" alt="47" width="30" height="30" id="n47" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b48.gif" name="n48" alt="48" width="30" height="30" id="n48" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b49.gif" name="n49" alt="49" width="30" height="30" id="n49" /></a></td>
<td><a href="#ketokdo"><img src="images/design/loto_gif/b50.gif" name="n50" alt="50" width="30" height="30" id="n50" /></a></td>
</tr>
</table><br />
</div>
<form method="post" action="verife.php">
<input name="pseudo" size="19" value="<?php echo $pseudo ?>" readonly="readonly"><br /><br />
<strong>Tes numéros joués aujourd'hui: </strong><br /> <br />
<input type="text" name="x1" size="2" id="x1">-
<input type="text" name="x2" size="2">-
<input type="text" name="x3" size="2">-
<input type="text" name="x4" size="2">-
<input type="text" name="x5" size="2">-

<strong>Numéro complémentaire</strong> :
<input type="text" name="xbonus" size="2"> <br /><br />
<br />
<br />
<input type="submit" value="Cliques ici pour valider ton KetoLoto" class="boutons">
</form> ----------------------------------------------------------------------
/  La vie ne vaut rien mais rien ne vaut la vie !!!!!  /
----------------------------------------------------------------------

Répondre à cheese42

6

 cheese42, le 25 fév 2009 à 14:00:20

Je suppose que tu as compris ma page ^^^, bah, c'est pour faire un loto, et je voudrais que plutot que le membre ecrive les numeros qu'il veut, bah qu'il clique sur l'image du no et que ca l'affiche dans le input^^ ------------------------------------------------------------­----------
/  La vie ne vaut rien mais rien ne vaut la vie !!!!!  /
------------------------------------------------------------­----------

Répondre à cheese42