DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Disable/Lock Text Input Form Fields (http://www.daniweb.com/forums/thread91092.html)

LOVE4CODE Sep 29th, 2007 3:30 am
Disable/Lock Text Input Form Fields
 
I've created a admin center, that has two seperate login permissions. Admin which can edit listings, etc... and Viewer which can only view listings, and edit 1 or 2 of the listings details and not all of them like the admin.

I've seen web-sites where certain text input fields are sort of Grayed out, not allowing for user to type, click in or change anything in that field. Sort of like the html text input field has been or is disabled...

My Question: How can I get certain html text input fields to appear disabled, and the text that's inside un-editable or unchange-able?

Thank you much

~s.o.s~ Sep 29th, 2007 1:02 pm
Re: Disable/Lock Text Input Form Fields
 
> How can I get certain html text input fields to appear disabled, and the text that's inside
> un-editable or unchange-able?
You have got to realize that 'disabled' doesn't mean or equate to 'readonly'. Both these properties disallow the user from editing the entered text but the real difference comes when you try retrieving the form element values at the server. If the element is marked with the property 'disabled', the form element value won't be submitted to the server while a form elements' value marked 'readonly' will be.

<input type="text" name="txtName" id="txtName" readonly="readonly" />
<input type="text" name="txtName" id="txtName" disabled="disabled" />

Zion_Lion Jul 30th, 2009 12:41 am
Re: Disable/Lock Text Input Form Fields
 
Thank you ~s.o.s~

benjiei Jul 30th, 2009 4:20 am
Re: Disable/Lock Text Input Form Fields
 
Quote:

Originally Posted by ~s.o.s~ (Post 442791)
> How can I get certain html text input fields to appear disabled, and the text that's inside
> un-editable or unchange-able?
You have got to realize that 'disabled' doesn't mean or equate to 'readonly'. Both these properties disallow the user from editing the entered text but the real difference comes when you try retrieving the form element values at the server. If the element is marked with the property 'disabled', the form element value won't be submitted to the server while a form elements' value marked 'readonly' will be.

<input type="text" name="txtName" id="txtName" readonly="readonly" />
<input type="text" name="txtName" id="txtName" disabled="disabled" />


Thanks you very much...im newbies in web programming...God bless


All times are GMT -4. The time now is 9:24 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC