Page 1 sur 1

petit bou de code qui fait des sienne :-(

Posté : 16 juin 2007, 18:40
par hayes
Bonjour à tous, j'avais un jolie code comme celui-ci qui fonctionnait bien :
<table width="75%" border="0" cellspacing="0">
              <tr>
                <td height="181" align="center">
                    <p><img src="interface/etape1_a.jpg" width="164" height="132"><br>
                      <input type="button" onClick="javascript:decremente(document.formulaire.bouille);" value="&nbsp;-&nbsp;">
                      <input type="TEXT" name="bouille" value="{PERSO1}" size="1" readonly>
                      <input type="button" onClick="javascript:incremente(document.formulaire.bouille);" value="&nbsp;+&nbsp;">
                    </p>
                </td>
                <td align="center">
                    <p><img src="interface/etape1_b.jpg" width="164" height="132"><br>
                      <input type="button" onClick="javascript:decremente(document.formulaire.celebre);" value="&nbsp;-&nbsp;">
                      <input type="TEXT" name="celebre" value="{PERSO2}" size="1" readonly>
                      <input type="button" onClick="javascript:incremente(document.formulaire.celebre);" value="&nbsp;+&nbsp;">
                    </p>
                </td>
                <td align="center">
                    <p><span class="contractuelle"><img src="interface/etape1_c.jpg" width="164" height="132"></span><br>
                      <input type="button" onClick="javascript:decremente(document.formulaire.anima);" value="&nbsp;-&nbsp;">
                      <input type="TEXT" name="anima" value="{PERSO3}" size="1" readonly>
                      <input type="button" onClick="javascript:incremente(document.formulaire.anima);" value="&nbsp;+&nbsp;">
                    </p>
                </td>
              </tr>
            </table>
Et je l'ai remplacé par celui-ci pour avoir de jolies boutons au lieu d'avoir des bontons standart, mais ça fonctionne pas terrible... lorsque je clic sur le bouton + ou - ca valide automatiquement maintenant... Arf! Ausecour, je suis débutant.
<table width="75%" border="0" cellspacing="0">
              <tr>
                <td height="181" align="center">
                    <p><img src="interface/etape1_a.jpg" alt="abc width="164" height="132"><br>
                      <input name="button" onClick="javascript:decremente(document.formulaire.bouille);" value="&nbsp;-&nbsp;" type="image" src="interface/bt_moin.gif" onmouseover="this.src='interface/bt_moin_push.gif'" onmouseout="this.src='interface/bt_moin.gif'">
                      <input type="TEXT" name="bouille" value="{PERSO1}" size="1" readonly>
                      <input name="button" onClick="javascript:incremente(document.formulaire.bouille);" value="&nbsp;-&nbsp;" type="image" src="interface/bt_plus.gif" onmouseover="this.src='interface/bt_plus_push.gif'" onmouseout="this.src='interface/bt_plus.gif'">
                    </p>
                </td>
                <td align="center">
                    <p><img src="interface/etape1_b.jpg" alt="abc" width="164" height="132"><br>
                      <input name="button" onClick="javascript:decremente(document.formulaire.celebre);" value="&nbsp;-&nbsp;" type="image" src="interface/bt_moin.gif" onmouseover="this.src='interface/bt_moin_push.gif'" onmouseout="this.src='interface/bt_moin.gif'">
                      <input type="TEXT" name="celebre" value="{PERSO2}" size="1" readonly>
                      <input name="button" onClick="javascript:incremente(document.formulaire.celebre);" value="&nbsp;+&nbsp;" type="image" src="interface/bt_plus.gif" onmouseover="this.src='interface/bt_plus_push.gif'" onmouseout="this.src='interface/bt_plus.gif'">
                    </p>
                </td>
                <td align="center">
                    <p><span class="contractuelle"><img src="interface/etape1_c.jpg" alt="abc" width="164" height="132"></span><br>
                      <input name="button" onClick="javascript:decremente(document.formulaire.anima);" value="&nbsp;-&nbsp;" type="image" src="interface/bt_moin.gif" onmouseover="this.src='interface/bt_moin_push.gif'" onmouseout="this.src='interface/bt_moin.gif'">
                      <input type="TEXT" name="anima" value="{PERSO3}" size="1" readonly>
                      <input name="button" onClick="javascript:incremente(document.formulaire.anima);" value="&nbsp;+&nbsp;" type="image" src="interface/bt_plus.gif" onmouseover="this.src='interface/bt_plus_push.gif'" onmouseout="this.src='interface/bt_plus.gif'">
                    </p>
                </td>
              </tr>
            </table>

Posté : 18 juin 2007, 10:06
par Ryle
Le type "image" pour un input équivaut à un bouton de type submit, ce qui va avoir pour effet d'envoyer le formulaire... tu risques donc effectivement d'obtenir des effets non désirés...

Tu peux rester sur des input de type "button" et jouer sur le style (bordures, backgrounds, etc.) voire améliorer un peu ces boutons en utilisant la balise <button></button> qui te permet d'insérer une image pour changer un peu l'aspect :)
<button type="button" name="..." onClick="...">
  <img src="..." alt="..."> 
  texte du bouton 
</button> 

Posté : 18 juin 2007, 11:01
par hayes
ah, bah tampis alors, je vais essayer comme ça, merci pour ton aide :wink: