title: vbscript to disable/enable html input
body: <p>I have been working this one for a couple of days and I still haven't figured it out.  I have an HTML page that has two sets of inputs, each consisting of a radio button and some text.  I need:</p>
  
  <ul>
  <li>all of the text input to be disabled when the page loads</li>
  <li>radio button #1 to enable it's text input and disable the text inputs for radio button #2</li>
  <li>radio button #2 to enable it's text input and disable the text inputs for radio button #1</li>
  </ul>
  
  <p>Here's some example code:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;script type="text/vbscript"&gt;
  &lt;!--&lt;![CDATA[
  function enable()
      if document.GetElementByID("radio1").checked then
          document.GetElementByID("radio2").checked = false
          document.GetElementByID("text1").disabled = false
          document.GetElementByID("text2").disabled = true
      elseif document.GetElementByID("radio2").checked then
          document.GetElementByID("radio1").checked = false
          document.GetElementByID("text1").disabled = true
          document.GetElementByID("text2").disabled = false
      else
          document.GetElementByID("text1").disabled = true
          document.GetElementByID("text2").disabled = true
      end if
  end function
  --&gt;]]&gt;
  &lt;/script&gt;
  
  &lt;body onload="enable()"&gt;
      &lt;table border=1&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;input type="radio" id="radio1" name="radio1" value="radio1" onclick="enable()"&gt;
                  &lt;label for="radio1" &gt;
                      Radio 1
                  &lt;/label&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="text" id="text1" name="text1" value="hi"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;input type="radio" id="radio2" name="radio2" value="radio2" onclick="enable()"&gt;
                  &lt;label for="radio2" &gt;
                      Radio 2
                  &lt;/label&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="text" id="text2" name="text2" value="bye"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>It looks like I can get it partially working, but not all the way.  Eventaully, this will end up in an HTA as a form.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>Thanks to both @kingdomcreation and @Teemu, I now have this working solution for an arbitrary number of radio buttons:</p>
  
  <pre><code>&lt;html&gt;
  
      &lt;script type="text/vbscript"&gt;
          &lt;!--&lt;![CDATA[
          function enable(num)
              document.getElementById("text" &amp; num).disabled = false
  
              for i = 1 to 6
                  if document.getElementById("radio" &amp; i).checked = false Then
                      document.getElementById("text" &amp; i).disabled = true
                  end if
              next
          end function
          --&gt;]]&gt;
      &lt;/script&gt;
  
      &lt;body&gt;
          &lt;table border=1&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="radio" id="radio1" name="radio" value="radio1" onClick="enable(1)"&gt;
                      &lt;label for="radio1" &gt;
                          Radio 1
                      &lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input disabled type="text" id="text1" name="text1" value="hi"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="radio" id="radio2" name="radio" value="radio2" onClick="enable(2)"&gt;
                      &lt;label for="radio2" &gt;
                          Radio 2
                      &lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input disabled type="text" id="text2" name="text2" value="there"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="radio" id="radio3" name="radio" value="radio3" onClick="enable(3)"&gt;
                      &lt;label for="radio3" &gt;
                          Radio 3
                      &lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input disabled type="text" id="text3" name="text3" value="how"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="radio" id="radio4" name="radio" value="radio4" onClick="enable(4)"&gt;
                      &lt;label for="radio4" &gt;
                          Radio 4
                      &lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input disabled type="text" id="text4" name="text4" value="are"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="radio" id="radio5" name="radio" value="radio5" onClick="enable(5)"&gt;
                      &lt;label for="radio5" &gt;
                          Radio 5
                      &lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input disabled type="text" id="text5" name="text5" value="you"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="radio" id="radio6" name="radio" value="radio6" onClick="enable(6)"&gt;
                      &lt;label for="radio6" &gt;
                          Radio 6
                      &lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input disabled type="text" id="text6" name="text6" value="bye"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>