PDA

View Full Version : Javascript: how do you hide buttons?


mouse
01-29-2003, 06:06 PM
Hi,

I have done a quick search on the forums but couldn't find what I was looking for. Basically I have two buttons on a page that I want to hide. I only want to unhide them depending on a users security access. If the user has the right access, then I want to allow the buttons to be visible.

The security aspect I will deal with. The first thing I want to know is how do I hide these buttons initially.

Thanks,

Mouse

Dr. Web
01-29-2003, 10:15 PM
this would be better suited for server side coding. Are you doing any?

If not, then how will you be holding the users authority level?

mouse
01-29-2003, 10:38 PM
hi,

I have the security aspect of this set up now, so that a button is visible depending on the users security profile.

This was done on the server side using jsp & struts tag libraries.

Now what i need to do is this.

I have a page called analyseContent.jsp that is shown within a frame in one section of the website called Adhoc reporting.

This analyseContent.jsp page will also be accessed in another section of the website called Reporting.

In the reporting section, I will access the analyseContent.jsp page by the click of a button. On the analyseContent.jsp I want to show the two buttons, ie make them visible. The two buttons are Save Exhibit and Restore Bookmark (although Save Exhibit button is only shown depending on the security access. The Restore Bookmark button is available to all users).

IN adhoc reporting I do not want these two buttons to be visible at all. Is the best way to control this to be a div around it and make the div hidden or visible? I have seen afew examples of divs being used to show or hide fields. But not sure how you hide buttons.

BTW - i also pass in a parameter to the analyseContent.jsp page

analyseContent.jsp?mode=analyse

So if it is analyse then show these buttons. Need to work with it like this somehow.

Thanks
Mouse

Dr. Web
01-29-2003, 11:14 PM
since your using JSP then you would use JSP to look at the security, and display if appropriate.

For instance I store authorityLevel in a session variable.

So I would say:

if(authorityLevel > 5){
/* execute JSP code that writes out buttons */
}

thats it. (insert your tracked authority for the user in for authorityLevel).

mouse
01-30-2003, 12:01 AM
Hmmmmmm,

I have security controlling whether or not a user should see the Save Exhibit button. This is controlled on the server side.

Now i don't know, if on server side or the client side, I need to control whether the button is hidden or not. But just say I enter into the Adhoc area and the analyseContent.jsp loads into view. I do not want to see the Save Exhibit Button or the Restore Bookmark button, regardless of security access role.

If I go into the Reporting and I load the analyseContent.jsp page up, I want to definitely see the Restore Bookmark button, but depending on security access role, I may or may not see the Save Exhibit button. (I have that aspect working). My problem is I am calling the same page in two different areas of the web site. In adhoc I don't want to give the users the functionality of clicking on the Restore Bookmark or Save Exhibit buttons, but in the reporting are of the website, when I access the AnalyseContent.jsp I do want to access those buttons. Hence the reason I pass in the following paramter when going into the reporting area of the website.

analyseContent.jsp?mode=analyse

Anyway, is it possible to hide a button or not on a page on the client side? If so, how would I do this?

Dr. Web
01-30-2003, 12:01 PM
simple. You still use JSP, just look for the document.referrer... and if its NOT the adhoc area, then show the buttons (depending on the security level).

additionally, you could pass in a parameter (maybe something like 01987=001001 and just make those values obscure to confuse the user, but to show/ hide the button.

Example:

url=http://report.jsp?01987=001001

jsp page:

if(url.01987==001001){show buttons}else{do not show}