To invoke a textbox when radio button clicked

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • januincse
    New Member
    • Sep 2008
    • 1

    #1

    To invoke a textbox when radio button clicked

    There 2 radio buttons.when a radio is clicked textbox should appear,when another radio clicked the existing textbox should disappear and new textbox should be enabled.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    sounds like a neat effect.....

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      Use onclick event of the radio buttons to display and hide the textareas accordingly. style.display can be useful.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Not a HTML question. Moved to the JavaScript/DHTML forum.

        Moderator.

        Comment

        • Rsmastermind
          New Member
          • Sep 2008
          • 93

          #5
          onclick of the radio call a function like this
          [HTML]
          <input type="radio" id="myRadio" name="myRadio" onclick="enable _disable();"\>
          <input type="text" id="myRadioText one" name="myRadioTe xt" class="optional " style="display: none"/>

          <input type="text" id="myRadioText two" name="myRadioTe xt" class="optional " style="display: none"/>[/HTML]

          Code:
          function enable_disable()
          {
          
          var textFieldone=document.getElementById('myRadioTextone');
          var textFieldtwo=document.getElementById('myRadioTexttwo');
          textFieldone.style.display='block';
          textFieldtwo.style.display='none';
          }
          similiarly for the second radio do viceversa

          Comment

          Working...