textbox - Control Textboxes (enable/disable) with radio buttons - jQuery -


i controlling textboxes, enable / disable, depending on selected radio button - jquery preferable.

if radio button selected associated textboxes enabled - others disabled. same thing scenarios. 1 radio button pre selected.

here markup:

     <div>             <h1>control fields</h1>             <div id="div1">                 <div id="first">                     <input type="radio" name="radio" id="radio3" checked="checked" />first</br>         <input type="text" id="txt_one" /></br>         <input type="text" id="txt_two" /></br>                 </div>                 <div id="second">                     <input type="radio" name="radio" id="radio4" />second</br>                     <input type="text" id="three" /></br>       <input type="text" id="txt_four" /></br>                 </div>                  <div id="third">                     <input type="radio" name="radio" id="radio5" checked="checked" />first</br>         <input type="text" id="txt_five" /></br>         <input type="text" id="txt_six" /></br>         <input type="text" id="txt_seven" /></br>                 </div>             </div>         </div> 

here link to: http://jsfiddle.net/9cdch/1/

i think may have you're looking for. here jquery:

$('.radioexample').not('.first').siblings().prop('disabled',true);  $('.radioexample').on('click',function(){     $('.radioexample')         .siblings()         .prop('disabled',true);      $(this)         .siblings()         .prop('disabled',false); }); 

to this, add class radioexample each radio, , first first radio button. disables siblings of radio buttons after first 1 (checked default) on page load, , on each click redisables , enables siblings 1 clicked.

i've updated jsfiddle well.

there couple of ways (another way classes added or removed), 1 came mind first.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -