[javascript]Onclick & button

Buzzz -  
 Buzzz -
Salut a tous,
voila je voudrait choisir d'ouvrir des pages html grace a des boutons mais je seche un peu si quelqu'un sait comment on s'y prend son aide ne sera pas de refus!
voila j'avais pensé a quequechose du style:

dans un fichier accesadmin.html:
<html>
  <head>
    <title>acces administrateur</title>
    <script language="javascript" type="text/javascript" src="Fonctions.js"></script>
  </head>
  <body>
    <h3><center>que voulez vous modifier?<br></center></h3>
    <a onClick="choix(name)"><center>
        <input type="button" name="truc" value="truc">
        <input type="button" name="bidule" value="bidule">
    </center></a>
  </body>
</html>

et dans un fichier Fonctions.js:
function choix(nom){
  if    (nom == 'truc') windows.open("creatruc.html","_self");
  else  (nom == 'bidule') windows.open("creabidule.html","_self");
}

mais bon bien entendu ça ne marche pas :(
si quelqu'un voit des erreurs ou si quelqu'un a une solution je l'en remercie
Tchô!!! ;-)

4 réponses

  1. flokocha Messages postés 1519 Statut Membre 281
     
    Et si tu faisais tout simplement :
    <body>
        <h3><center>que voulez vous modifier?<br></center></h3>
        <center>
            <input type="button" onClick="location.replace('creatruc.html');" value="truc">
            <input type="button" onClick="location.replace('creabidule.html');"  value="bidule">
        </center>
      </body>


    .::: "A trop vouloir feindre de faire fi, on finit 
    par faire fi de vouloir feindre." 
    :::.
    15
  2. Buzzz
     
    Merci de ta reponse mais il y a toujours une erreur!
    3
  3. Marden Messages postés 1075 Statut Membre 210
     
    Essaie quelque chose comme çà :
      <body>
        <h3><center>que voulez vous modifier?<br></center></h3>
        <center>
            <input type="button" onClick="choix('creatruc.html')" value="truc">
            <input type="button" onClick="choix('creabidule.html')"  value="bidule">
        </center>
      </body>

    avec :
    function choix(nom){
      windows.open(nom,"_self");
    }
    2
  4. Buzzz
     
    Merci, !-)
    j'ai tendance a me compliquer la vie!
    A+
    2