Jump to content

Dynamic menus


Recommended Posts

Hi,

Am wanting to create dynamic menus based on user roles. Found an example from the Caspio forum.

This example is not working for me. For some reason it's not getting to execute the IF statement. If I add display statements before and after the IF statement, they run properly.

May I be advised as to why the IF statement on the below example is not working. Please advise.

<div id="menu"></div>

<script>
document.addEventListener('DataPageReady', function (event) {
if("[@authfield:Role]" == "Admin"){
document.getElementById('menu').innerHTML = '[@app:Admin]';
}
else if ("[@authfield:Role]" == "Agent"){
document.getElementById('menu').innerHTML =  '[@app:Agent]';
}
});
</script>
Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...