[javascript]Onclick & button

Fermé
Buzzz - 16 juin 2004 à 15:35
 Buzzz - 17 juin 2004 à 09:47
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

flokocha Messages postés 1510 Date d'inscription lundi 8 mars 2004 Statut Membre Dernière intervention 10 octobre 2015 280
16 juin 2004 à 16:29
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
Merci de ta reponse mais il y a toujours une erreur!
3
Marden Messages postés 1072 Date d'inscription dimanche 11 février 2001 Statut Membre Dernière intervention 29 janvier 2006 208
16 juin 2004 à 16:01
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
Merci, !-)
j'ai tendance a me compliquer la vie!
A+
2