Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle type=password and type=textarea

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
0
0
US
I've got some fields on my page that I don't want certain users to see. However, I don't want to hide the fields (page looks bad) and I don't want to set the foreground/background the same because then the user might think that there is no data in the field.

So I did something like this:

<Input...type=password>

However, if the user decides he wants to edit the data and has privileges to do so, I need to change the type to text or textarea or something so that the user can see the data. It appears that I can't reset the type property once it has been set.

Any ideas on how I can handle this?
 
Try setting the textarea to readonly to prevent editting, then set readonly to false to edit contents.

Otherwise, you can use display="none" to hide a div or other element with data in it, or display="block" to show the area with the data in it.

Lee
 
I was hoping there was another way. Some of the data is sensitive so we don't want users to see it (except for their own information). So read only wouldn't work. I hate to hide the fields because the layout of my page would not look good. But, I may have to hide them if there is no other option. I guess I could place one control on top of the other. One would be the password field and the other a text field. And then just toggle the visiblity property on/off. Seems like kind of a hastle though. I've got about a dozen fields to deal with.
 
If you use the display property, set it to block or none, the block won't take up any space on the page when hidden. Display one block for those who aren't supposed to see something, or another for those who are supposed to have acccess to it. If you'd use server-side scripting (like ASP), this wouldn't be an issue because you could write the page dynamically based on the user.

Lee
 
Some of the data is sensitive so we don't want users to see it
So the data shouldn't be sent at all for non authorised users as they may have a look at the HTML source ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You'll need an asp script to do this. Just generate the password or text version depending on the user
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top