How can i re execute a function multiple times with ejs and express

32 Views Asked by At

When I click on submit button, the code works, the tittle changes to the random band name, but when i click a second time, it just do nothing. I don't understand what the problem could be, but when I click submit, and "/submit" to get accessed it shows "?" after in the each bar .I am using express and EJS.

app.get("/", (req, res)=>
{
    res.render("index.ejs");
});
app.get("/submit", (req, res)=>
{
    res.render("index.ejs", { randomName: sillyName});
});
<body>
    <% if (locals.randomName) { %>
        <h1><%= randomName %> Band</h1>
        <% } else { %>
          <h1>Band name Generator </h1>
          <% } %>
        <form action="/submit" method="GET">
                <input type="submit" value="Start" id="subbutone">
        </form>
</body>
0

There are 0 best solutions below