"Uncaught SyntaxError: Unexpected end of input" Error in Html,Css,Js

Issue

Hello i Tried to run my code then it showed this error: "Uncaught Syntax Error: Unexpected end of input" could anyone help?

Solution

You are missing 2 closing brackets in your javascript you don’t close the document.getElementById functions:

document.getElementById("submit").onclick = function() {
 console.log("Submitted prize. Prize ID:");
  function makeid(length) {
    var result           = '';
    var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var charactersLength = characters.length;
    for ( var i = 0; i < length; i++ ) {
      result += characters.charAt(Math.floor(Math.random() * charactersLength));
    }
    return result;
    console.log(makeid(27));
  }
} // add this

Same for the other getElementById function.
If you keep your indentation the same you can prevent these errors.

Answered By – Casper Kuethe

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published