dynamically change visibility of input text in code igniter

I have a variable that i will pass from my controller to my view, lets call this variable $validate. This variable will help us to know in what state is the user in (Update or Save). I will ask user to input an ID and Password in Save state (input text id = enable, password = visible) But in Update state, i dont want user to update their ID and they cant see their Password (input text id = disable, password = invisible). Now for the input text id, i could do something like this : <input type="text" name="ID_user" class="text" <?php if($validate!='add'){echo "disabled";} ?> So no javascript are needed in the input text ID My Question are :

  1. How to make the input text password invisible according to $validate value?

  2. Can i use the same way like input text ID?(so no javascript are needed) Thanks :D

Note : i use the same form for Update and Save :D


Something like this - just use a simple 'if' switch statement

   <input type="text" name="id" id="id">
   <?php if ($validate!='add') {?>
           <input type="text" name="id" id="id">
           <input type="password" name="password" id="password">
   <?php } else { ?>
           <input type="text" name="id" id="id" disabled="disabled">
   <?php } ?>


edit: I'm assuming you are NOT wanting to 'POST' the password back to yourself when it is an update.

Need Your Help

AS3 how to load in external images in a loop?

flash actionscript-3 image load

I'm making a highscore table in flash using AS3, I have successfully got working code that displays the names and the scores but also part of my high score table it needs to display the users country

How to turn off authentication for websockets in Spring Security?

java spring java-ee spring-security websocket

I've got a Java EE application which uses Spring Security for authentication (configured with Java config). The same application contains a websocket server implemented with javax.websocket package...