0

So I have a login box and a registration box. I'm trying to update the view if register is clicked. the boolean is changing in the console but the view is not

index.ejs

    <%- include('partials/header') -%>

<% if (locals.isAuthenticated) { %>
    <p>You are logged in. <a href="/profile" class="underline">View your profile</a>.</p>
<% } else if (!this.isRegister) { %>
    <%- include('partials/loginbox') -%>
<% } else { %>
    <%- include('partials/registerbox') -%>
<% } %>

<%- include('partials/footer') -%>

script in body in footer.ejs:

<script>

    var isRegister = false;

function register() {
    this.isRegister = !this.isRegister;
    console.log(this.isRegister);
    return this.isRegister
};

</script>

button in loginbox.ejs:

                   <button type="button" class="btn btn-primary" onClick="register()">Register</button>
S-Grace
  • 25
  • 5
  • The EJS program is executed (presumably) on your HTTP server. The ` – Quentin Apr 19 '23 at 19:40
  • Thank you, coming from Angular so a quick conditional in the html works there. – S-Grace Apr 20 '23 at 19:44
  • @Quentin, How would I go about getting the update to work? I'm not familiar with EJS – S-Grace Apr 20 '23 at 19:45
  • Submit a form to the server. Send the new HTML back. – Quentin Apr 20 '23 at 21:09

0 Answers0