Mon code ne fonctionne pas

Résolu
jlchris Messages postés 3 Date d'inscription mercredi 7 septembre 2022 Statut Membre Dernière intervention 8 septembre 2022 - 7 sept. 2022 à 16:50
jlchris Messages postés 3 Date d'inscription mercredi 7 septembre 2022 Statut Membre Dernière intervention 8 septembre 2022 - 8 sept. 2022 à 16:59

Bonjour,

J'essaye de construire un code pour definir à partir d'une date de naissance l'ensemble des signe du zodiaque du monde, occidentale, chinois, celtique, africain, créole....

Malheureusement, je me retrouve bloqué et mon code ne veux pas fonctionner.

Je dois faire une erreur, mais où ? Je suis débutant.

Je vous remercie si quelqu'un peut m'aider.

Cordialement

voici mon code :

<html>
<head>
<title>Quel est votre signe </title>
<script type="text/javascript">

function signs() {
var start = 1901, birthyear = document.zodiac.year.value, date=document.zodiac.date.value, month=document.zodiac.month.selectedIndex;
with (document.zodiac.sign){
if (month == 1 && date >=20 || month == 2 && date <=18) {value = "Verseau";}
if (month == 1 && date > 31) {value = "Hein ?";}
if (month == 2 && date >=19 || month == 3 && date <=20) {value = "Poissons";}
if (month == 2 && date > 29) {value = "Vous dites ?";}
if (month == 3 && date >=21 || month == 4 && date <=19) {value = "Bélier";}
if (month == 3 && date > 31) {value = "Comme vous voulez.";}
if (month == 4 && date >=20 || month == 5 && date <=20) {value = "Taureau";}
if (month == 4 && date > 30) {value = "Je suis vraiment désolé !";}
if (month == 5 && date >=21 || month == 6 && date <=21) {value = "Gémeaux";}
if (month == 5 && date > 31) {value = "Euh... non.";}
if (month == 6 && date >=22 || month == 7 && date <=22) {value = "Cancer";}
if (month == 6 && date > 30) {value = "Désolé.";}
if (month == 7 && date >=23 || month == 8 && date <=22) {value = "Lion";}
if (month == 7 && date > 31) {value = "Pardon ?";}
if (month == 8 && date >=23 || month == 9 && date <=22) {value = "Vièrge";}
if (month == 8 && date > 31) {value = "C'est ça.";}
if (month == 9 && date >=23 || month == 10 && date <=22) {value = "Balance";}
if (month == 9 && date > 30) {value = "Essaie encore.";}
if (month == 10 && date >=23 || month == 11 && date <=21) {value = "Scorpion";}
if (month == 10 && date > 31) {value = "N'y pense même pas !";}
if (month == 11 && date >=22 || month == 12 && date <=21) {value = "Sagittaire";}
if (month == 11 && date > 30) {value = "Date invalide";}
if (month == 12 && date >=22 || month == 1 && date <=19) {value = "Capricorne";}
if (month == 12 && date > 31) {value = "Aucune chance !";}}
x = (start - birthyear) % 12
with (document.zodiac.csign){
if (x == 1 || x == -11) {value = "Rat";}
if (x == 0) {value = "Ox";}
if (x == 11 || x == -1) {value = "Tigre";}
if (x == 10 || x == -2) {value = "Lapin";}
if (x == 9 || x == -3)  {value = "Dragon";}
if (x == 8 || x == -4)  {value = "Serpent";}
if (x == 7 || x == -5)  {value = "Cheval";}
if (x == 6 || x == -6)  {value = "Mouton";}
if (x == 5 || x == -7)  {value = "Singe";}
if (x == 4 || x == -8)  {value = "Coq";}
if (x == 3 || x == -9)  {value = "Chien";}
if (x == 2 || x == -10) {value = "Cochon";}
with (document.zodiac.dsign){
if (month == 1 && date >=2|| month == 1 && date <=11) {value = "Sapin";}
if (month == 1 && date >=12|| month == 1 && date <=24) {value = "Orme";}
if (month == 1 && date >=25|| month == 2 && date <=3) {value = "Cyprès";}
if (month == 1 && date > 31) {value = "Hein ?";}
if (month == 2 && date >=4|| month == 2 && date <=8) {value = "Peuplier";}
if (month == 2 && date >=9|| month == 2 && date <=18) {value = "Cédre";}
if (month == 2 && date >=19|| month == 2 && date <=28) {value = "Pin";}
if (month == 2 && date > 29) {value = "Vous dites ?";}
if (month == 3 && date >=1|| month == 3 && date <=10) {value = "Saule pleureur";}
if (month == 3 && date >=11|| month == 3 && date <=20) {value = "Tilleul";}
if (month == 3 && date >=21|| month == 3 && date <=21) {value = "Chêne";}
if (month == 3 && date >=22|| month == 3 && date <=31) {value = "Noisetier";}
if (month == 3 && date > 31) {value = "Comme vous voulez.";}
if (month == 4 && date >=1|| month == 4 && date <=10) {value = "Cormier";}
if (month == 4 && date >=11|| month == 4 && date <=20) {value = "Erable";}
if (month == 4 && date >=21|| month == 4 && date <=30) {value = "Noyer";}
if (month == 4 && date > 30) {value = "Je suis vraiment désolé !";}
if (month == 5 && date >=1|| month == 5 && date <=14) {value = "Peuplier";}
if (month == 5 && date >=15|| month == 5 && date <=24) {value = "Châtaignier";}
if (month == 5 && date >=25|| month == 6 && date <=3) {value = "Frêne";}
if (month == 5 && date > 31) {value = "Euh... non.";}
if (month == 6 && date >=4|| month == 6 && date <=13) {value = "Charme de la Caroline";}
if (month == 6 && date >=14|| month == 6 && date <=23) {value = "Figuier";}
if (month == 6 && date >=24|| month == 6 && date <=24) {value = "Bouleau";}
if (month == 6 && date >=25|| month == 7 && date <=4) {value = "Pommier";}
if (month == 6 && date > 30) {value = "Désolé.";}
if (month == 7 && date >=5|| month ==7 && date <=1) {value = "Sapin";}
if (month == 7 && date >=15|| month == 7 && date <=25) {value = "Orme";}
if (month == 7 && date >=26|| month == 8 && date <=4) {value = "Cyprès";}
if (month == 7 && date > 31) {value = "Pardon ?";}
if (month == 8 && date >=5|| month == 8 && date <=13) {value = "Peuplier";}
if (month == 8 && date >=14|| month == 8 && date <=23) {value = "Cèdre";}
if (month == 8 && date >=24|| month == 9 && date <=2) {value = "Pin";}
if (month == 8 && date > 31) {value = "C'est ça.";}
if (month == 9 && date >=3|| month == 9 && date <=12) {value = "Saule pleureur";}
if (month == 9 && date >=13|| month == 9 && date <=22) {value = "Tilleul";}
if (month == 9 && date >=23|| month == 9 && date <=23) {value = "Olivier";}
if (month == 9 && date >=24|| month == 10 && date <=3) {value = "Noisetier";}
if (month == 9 && date > 30) {value = "Essaie encore.";}
if (month == 10 && date >=4|| month == 10 && date <=13) {value = "Cormier";}
if (month == 10 && date >=14|| month == 10 && date <=23) {value = "Erable";}
if (month == 10 && date >=24|| month == 11 && date <=11) {value = "Noyer";}
if (month == 10 && date > 31) {value = "N'y pense même pas !";}
if (month == 11 && date >=12|| month == 11 && date <=21) {value = "Châtaignier";}
if (month == 11 && date >=22|| month == 12 && date <=1) {value = "Frêne";}
if (month == 11 && date > 30) {value = "Date invalide";}
if (month == 12 && date >=2|| month == 12 && date <=11) {value = "Charme de la Caroline";}
if (month == 12 && date >=12|| month == 12 && date <=21) {value = "Figuier";}
if (month == 12 && date >=22|| month == 12 && date <=22) {value = "Hêtre";}
if (month == 12 && date >=23|| month == 1 && date <=1) {value = "Pommier";}
if (month == 12 && date > 31) {value = "Aucune chance !";}}

</script>
</head>

<body>

<form name="zodiac">
<table cellspacing="0" cellpadding="4">
    <tr>
        <td>Année</td>
        <td><div align="right"><input type="text" size="10" name="year" value="Année" onClick="value=''" /></div></td>
    <tr>
        <td>Mois</td>
        <td><div align="right"><select name="month">
        <option value="x">Choisissez un mois</option>
        <option value="1">Janvier</option>
        <option value="2">Février</option>
        <option value="3">Mars</option>
        <option value="4">Avril</option>
        <option value="5">Mai</option>
        <option value="6">Juin</option>
        <option value="7">Juillet</option>
        <option value="8">Août</option>
        <option value="9">Septembre</option>
        <option value="10">Octobre</option>
        <option value="11">Novembre</option>
        <option value="12">Décembre</option>
        </select></div></td>
    </tr>
    <tr>
        <td>Jour</i></b></td>
        <td><div align="right"><input type="text" name="date" value="Jour" size="3" onClick="value=''" /></td>
    </tr>
    <tr>
        <td colspan="2"><div align="center"><input type="button" value="Calculer..." onClick="signs()" /><hr size="1" color="black" /></div></td>
    </tr>
    <tr>
        <td>Votre signe du zodiaque :</td>
        <td><div align="right"><input type="text" name="sign" size="12"></div></td>
    </tr>
    <tr>
        <td>Votre signe chinois :</td>
        <td><div align="right"><input type="text" name="csign" size="12"></div></td>
    </tr>
    <tr>
        <td>Votre signe du zodiaque celtique :</td>
        <td><div align="right"><input type="text" name="dsign" size="12"></div></td>
    </tr>
    <tr>
</table>


</body>
</html>

2 réponses

hypothetix Messages postés 191 Date d'inscription dimanche 19 janvier 2020 Statut Membre Dernière intervention 24 avril 2024 6
8 sept. 2022 à 09:13

Bonjour

Pour présenter du code prière de suivre ce tuto : https://codes-sources.commentcamarche.net/faq/11288-poster-un-extrait-de-code

Cela donnera du code formaté, bien plus agréable et facile à lire.

Pour ton problème : il manque quelques accolades fermantes "}"
il doit en avoir autant que d'accolade ouvrante "{"

1
jlchris Messages postés 3 Date d'inscription mercredi 7 septembre 2022 Statut Membre Dernière intervention 8 septembre 2022
8 sept. 2022 à 16:59

Merci pour la réponse et je vais regarder pour présenter le code. Je suis nouveau.

Désolé pour la fatigue des yeux.

Cordialement

0
Rejoignez-nous