• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the problem, specifically?
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Normally, you can't dispath a form on several layers or div.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic