-1

Trouble hiding a div once a condition is met. Condition is based off who is logging into a web application.

I have a css file that has the multipleBox div set to visibility: hidden along with other attributes such as border color etc.

Tried to use a function in Ajax. Using DOM properties to change display/visibility of the div depending on who's logging in. No dice.

Also tried to change the div class with javascript. No luck as well.

This function is what I have currently that isn't working how I would like. It is called onload of the body.

function Hidder() { var valid = document.getElementById("form1:validate").value;

if (valid == true) {

    document.getElementById("multipleBox").style.visibility ="visible";
    }

}

No luck in switching between visibiliity or display.

I want it to remain hidden unless the person accessing the web app is an admin. I used jsf tags in my jsp page to retrieve the credential of the user. So the variable valid has a boolean stored in it from the jsp page.

WillaOMO
  • 1
  • 1

1 Answers1

-1

I think you document.getElementById("form1:validate").value is not how you would access an element by ID.

Try this document.getElementById("validate").value assuming 'validate' is the ID of your input field containing the boolean value.

Or use this to get value by form name and field id ="validate"

document.querySelector("form[name=formname] #validate").value