Home > Mobile >  How to get the value of that input text?
How to get the value of that input text?

Time:12-17

I have two roles admin and student, if the role is student then I want to hide the admin menu.

Html

<input id="role" value='<?php echo $_SESSION[$config["session"]]["role"];?>'>

Javascript

function loadPage(){
   if($("#role").val() == "student"){
       $("#admin-menu").hide()
   }
}

CodePudding user response:

You could add this to your menu container class

<?= ($_SESSION[$config["session"]]["role"] != admin ? 'hidden' : '') ?>

It would add class 'hidden' if the user's role is not admin

But the better practice is to use separate views for different user roles or|and do not render admin menu at all

CodePudding user response:

Call your function after document load.

$(document).ready(function() {
loadPage();
});
  • Related