0

i'm new to html, java script and css and i'm working on a project for the U and i have a doubt. I'm making a profile page that, depenging on the type of user, it should show specific information. To do that, i used the tag div to hide data that the entity Profile should not have because it has no these atributes. In other words, i have superclass "Profile" and to sub clases "freelance" and "cliente". freelance has the atribute "cumplimiento" and "cliente" doesn't.

        <div id="pfreelance" style="display: none">
            <h:outputLabel for="cumplitud" value="Score:"
                styleClass="control-label" />
            <p:inputText autocomplete="off" id="cumplitud"
                styleClass="form-control" style="margin: 0px 0px 10px 0px"
                value="#{perfilPageController.profile.cumplimiento}" maxlength="50"
                required="true" />

        </div>
        <div id="pcliente" style="display: none">

            <p>you are in page of Cliente</p>

        </div>

        <script type="text/javascript">
            var pf = document.getElementById("pfreelance");
            var pc = document.getElementById("pcliente");
            if ("#{perfilPageController.Bottom()}" == "c"){
                pc.style.display = "inline";
            }
            else if ("#{perfilPageController.Bottom()}" == "f"){
                pf.style.display = "inline";
            }
        </script>

i tried using style.display = "hidden" bt this just makes the div invisible, but doesn't stop it from loading. i know i may be making a lot of mistakes, but i want to know if there is a way to stop the div with id "pfreelance" from loading. if you have any suggestions of how i should fix my code?, i would be very grateful.

  • Starting with a good tutorial helps... – Kukeltje May 17 '20 at 05:47
  • thanks, it's exactly what i needed. – Sebastian R. May 17 '20 at 06:42
  • 1
    I also suggest a good beginner tutorial. Critical data (passwords, etc.) should be hidden server-side. See the [rendered](https://stackoverflow.com/questions/4870462/conditionally-displaying-jsf-components/4870557#4870557) attribute or [JSTL tags](https://stackoverflow.com/questions/17587304/how-to-use-if-else-condition-in-jsf-to-display-image). Or use javascript ([see this](https://stackoverflow.com/questions/6242976/javascript-hide-show-element)) – fuggerjaki61 May 17 '20 at 08:49

0 Answers0