www.webdeveloper.com
Results 1 to 2 of 2

Thread: Trouble enabling elements disabled by javascript

  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Trouble enabling elements disabled by javascript

    Hello,
    I am trying to disable/enable a drop down list and a textarea by selecting one of two radio buttons. The disabling works fine but when I try to enable I am unsuccessful.
    function doesCenterHavWindows(e,f,g){
    var hasWindows = g; //1 == YES; 0 == NO
    var answer = document.getElementById(e);
    var comment = document.getElementById(f);

    if(hasWindows == 1){
    //set the answer
    answer.disabled = false;
    comment.disabled = false;
    answer.options[0] = ' ';
    answer.selectedIndex = 0;
    document.testingCenterWindows[0].checked = true;
    document.testingCenterWindows[1].checked = false;
    }
    else{
    answer.options[0].text = 'N/A';
    answer.selectedIndex = 0;
    answer.value = 'N';
    comment.value = ' ';
    answer.disabled = true;
    commnet.disabled = true;
    document.testingCenterWindows[0].checked = false;
    document.testingCenterWindows[1].checked = true;
    }

    }

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,364

    Lightbulb

    See if you can modify this...
    Code:
    <!DOC HTML>
    <html>
    <head>
    <title> Untitled </title>
    <script type="text/javascript">
    function ChangeStatus(IDS) {
      document.getElementById('SBox').disabled=true;
      document.getElementById('TArea').disabled=true;
     
      document.getElementById(IDS).disabled=false;
    }
    </script>
    </head>
    <body>
    <input type="radio" name="SBox_TArea" value="SBox" onclick="ChangeStatus(this.value)" checked> Select Box 
    <input type="radio" name="SBox_TArea" value="TArea" onclick="ChangeStatus(this.value)"> Textarea 
    <p>
    <select id="SBox">
     <option value="">Choose</option>
     <option value="">Item 1</option>
     <option value="">Item 2</option>
     <option value="">Item 3</option>
     <option value="">Item 4</option>
     <option value="">Item 5</option>
    </select>
    <textarea id="TArea" disabled=true></textarea>
    </body>
    </html>
    You should enclose your script between [ code] and [ /code] tags (without the spaces)
    to make it easier to view your problem and preserve the formatting.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles