Jump to content

Disbable or Hide Menu


Recommended Posts

I understand that I create separate pages and jump to a particular page based on a authentication record, but this technique creates logistical problems. It is hard to keep track of everything and making changes,say, to the menu structure is cumbersome. What I would like is some way to enable/disable or show/hide menus based on the user's status. Then there would be only one page. I have been searching the internet for examples without much success. Has anyone dealt successfully with this?

Thanks.

Edit: my menus are Spry through Dreamweaver, so I should probably ask them for help. In the meantime, I have just put "X" as the text and removed the link. It's a workaround, but I sort of like the look.

Link to comment
Share on other sites

Have you tried to see if you can perform this using RULES: http://howto.caspio.com/datapages/creating-conditional-forms-with-rules.html

I don't think this will work. I'm not using a form to display the data. I was looking for some Javascript magic that would do the trick, but I'm just getting use to Javascript so I do not even know where to start. Anyway, my workaround as discussed above is satisfactory for now. Thanks for the suggestion.

Link to comment
Share on other sites

  • 3 months later...

I understand how to create a view linking two tables by say... BuyerID... but can't figure out how to list the demographics just ONCE and then the products purchased in a report where multiple buyers are listed... each with their demographics, then purchased items below.

__________________________________________________________

Thl Phone THL W1+ ThL W3+

Link to comment
Share on other sites

  • 1 year later...

I had the same problem.

I am not sure that it is the best solution, but maybe it will be useful.

 

Firstly, I have grouped menu links in tags. The following code is the example for "Admin" links:

<div id="menu_for_admin">
<a href="URL">first admin url</a><br>
<a href="URL">second admin url</a><br>
<a href="URL">third admin url</a><br>
</div>

Then I add tags for Authentication parameters and hide it with the "style="display:none" code.

For example, for the admin role:

<div id="is_admin" style="display:none">[@authfield:admin]</div>

And then I have entered the script.

Firstly, the script creates variables for every block, for example, for the admin block I have used the following code:

var admin_menu = document.getElementById("menu_for_admin");

Then the script code that checks what is the role of the authenticated user, display her/his block and hide other.

For example, for the "member" role I have used the following code:

if (is_admin=="Yes")
{
 admin_menu.style.display = 'inline'; 
 member_menu.style.display = 'none';
 guest_menu.style.display = 'none';
}
    else
    {
        NEXT ROLE
     }

And now the whole code of the HTML page for three roles:

<div id="menu_for_admin">
<a href="URL">first admin url</a><br>
<a href="URL">second admin url</a><br>
<a href="URL">third admin url</a><br>
</div>
<div id="menu_for_member">
<a href="URL">first member url</a><br>
<a href="URL">second member url</a><br>
<a href="URL">third member url</a><br>
</div>
<div id="menu_for_guest">
<a href="URL">first guest url</a><br>
<a href="URL">second guest url</a><br>
<a href="URL">third guest url</a><br>
</div>

<div id="is_admin" style="display:none">[@authfield:admin]</div>
<div id="is_member" style="display:none">[@authfield:member]</div>

<script type="text/javascript">
var admin_menu = document.getElementById("menu_for_admin");
var member_menu = document.getElementById("menu_for_member");
var guest_menu = document.getElementById("menu_for_guest");

var is_admin = document.getElementById("is_admin").innerHTML;
var is_member = document.getElementById("is_member").innerHTML;

if (is_admin=="Yes")
{
admin_menu.style.display = 'inline';
member_menu.style.display = 'none';
guest_menu.style.display = 'none';
}
else
  {
    if (is_member=="Yes")
    {
     admin_menu.style.display = 'none';
     member_menu.style.display = 'inline';
     guest_menu.style.display = 'none';
    }
    else
    {
        admin_menu.style.display = 'none';
        member_menu.style.display = 'none';
        guest_menu.style.display = 'inline';
     }
  }
</script>
Link to comment
Share on other sites

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...
 Share

×
×
  • Create New...