my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Making a input text field readonly.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Making a input text field readonly.." Watch "Making a input text field readonly.." New topic
Author

Making a input text field readonly..

Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
Hi everyone,
I am trying to make a text input field in a form readonly when I select a particular radio button.
I used the foll. code to for this functionlity:
function changeTextField(typeOfRadioButtonClicked){
if(typeOfRadioButtonClicked == 1){
document.<formName>.<fieldName>.readOnly = true;
}
else if(typeOfRadioButtonClicked == 2){
document.<formName>.<fieldName>.readOnly = false;
}
}
I do not want to disable this text input field as I need to send these value to the server for further processing.
This works perfectly fine in IE but does not work in Netscape.
Can anybody give me hints as to how I can this functionality in Netscape?
Thank you
Chuck
Brian Glodde
Ranch Hand

Joined: Jun 27, 2001
Posts: 171
I can only think of one "messy" way...that is to fire a focus event on each textfield, then set a variable from the radio button event so you can check against it with the focus event. Then you could just blur them out of the textfield. Ugly but it would probably work.
Shivkumar Soni
Greenhorn

Joined: Nov 02, 2001
Posts: 2
use this ..
<input type=text name=txtfld onFocus="blur()">

This will solve your problem
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making a input text field readonly..
 
Similar Threads
Javascript..
readonly field
Want to display non editable in a frame
text field uneditable
AJAX JSP Calendar