• Bonjour, je n’arrive pas à utiliser le script sur mon site [ Redundant like redacted ] alors qu’il est bien fonctionnel aucune erreur du code.J’ai testé sur mon autre site chez wix.com ?a marche.

    Lorsque je clic sur ? valider ? je devrais voir appara?tre ? résultat : x ? (x= chiffre) hors rien n’appara?t voici le code vous pouvez le tester , en appuyant sur ? run ? via ce site https://www.w3schools.com/code/tryit.asp?filename=FWJKJM9M0UYS .

    Si quelqu’un aurait la solution svp ?

    • This topic was modified 6 years, 4 months ago by Jan Dembowski.
    • This topic was modified 6 years, 4 months ago by bcworkz. Reason: lower case title

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    There is unescaped line feeds in the string literal on your page at the document.getElementById line. You can’t do that in JavaScript. This is not how your w3schools example is formatted, there it is one long line. Some place a backslash at the end of string lines, which in essence escapes the line feed, but it’s not valid JavaScript. Either live with the long line or break string elements at the + concatenation operator.
    You have

    document.getElementById("answer").innerHTML = '</p>
    <div id="just">Résultat : ' + result +' €</div>
    <p>';

    Try

    document.getElementById("answer").innerHTML = 
        '<p><div id="just">Résultat : ' + result
         +' €</div></p>';

    Your opening and closing p tags seem to be reversed, I switched them in my example.

    One small nit pick: please do not use all caps titles when posting topics in these forums. There’s no need to SHOUT ??

    Thread Starter alaeddine69

    (@alaeddine69)

    @bcworkz thank you for your answer, I changed the code as you prefer me https://www.w3schools.com/code/tryit.asp?filename=FWPBOLPAQVW2 but it still does not work for me page clicks on “validate” the result is not displayed, I do not see the problem: https://aladdinprono.fr/1094-2/

    • This reply was modified 6 years, 4 months ago by alaeddine69.
    • This reply was modified 6 years, 4 months ago by alaeddine69.
    Moderator bcworkz

    (@bcworkz)

    Besides having redundant HTML and function names, both scripts are missing two closing }} at their end. Get rid of the redundancies and add the missing closing braces and the code will work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Script non fonctionnel seulement sur mon site’ is closed to new replies.