File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes how to disable text input field and change color or text box? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to disable text input field and change color or text box?" Watch "how to disable text input field and change color or text box?" New topic
Author

how to disable text input field and change color or text box?

Dennis Chen
Greenhorn

Joined: Aug 15, 2001
Posts: 10
Hi gurus,
I have two radio buttons and under each radio button I have a few text input fields. I need to disable the text fields based on the radio option selection along with greying out the text area so as to let the user know that it is unavailble.
Any help is appreciated.
Thanks!!!
Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
That could be done in the following manner:
Assumptions: radio is the name of all the radio buttons
for(var i=0; i<document.formName.radio.length; i++)
{
if(document.formName.radio[i].checked="1" && document.formName.radio[i].value="firstRadioButton")
{
document.formName.textBoxName.disabled="true";
}
}
Hope that helps.
Dennis Chen
Greenhorn

Joined: Aug 15, 2001
Posts: 10
Thanks. But I found a solution to it using <div> tags and onClick. The only problem I am having now is form validation on the input text fields between the <div>. Is there a way around it?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
What is the problem, specifically?
Brian Glodde
Ranch Hand

Joined: Jun 27, 2001
Posts: 171
It's hard to say what's wrong without seeing any code, however most of the time you're having trouble reaching an element inside a div, it's the way you're calling through the DOM. Try using document.all['elementname'] for ie and document.layers['elementname'] and see if that gets you a reference.
xavier romea
Ranch Hand

Joined: Jun 28, 2001
Posts: 37
Normally, you can't dispath a form on several layers or div.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to disable text input field and change color or text box?