Friday 11 April 2014

code is working in fiddle but not working in my system

If your code is not working in jsfiddle.net , then write your code in ready function, Like...

$(document).ready(function(){

// code here


});

Thursday 10 April 2014

Hide 2 Textbox When clicking on 1 Radio box

 

radio_example.php

   <input type="radio" class="radioBtn" name="radioBtn" id="radio1" /> radio 1 &nbsp;
   <input type="radio" class="radioBtn" name="radioBtn" id="radio2" /> radio 2 &nbsp;
   <input type="radio" class="radioBtn" name="radioBtn" id="radio3" /> radio 3

   <br />
   <input type="text" class="textBox" id="text1" value="text 1" /> &nbsp;
   <input type="text" class="textBox" id="text2" value="text 2" /> &nbsp;
   <input type="text" class="textBox" id="text3" value="text 3" />


radio_js.js

$(".radioBtn").click(function()
     {
      //  $(".textBox").hide();
        if ($(this).attr("id") == "radio1") {
            $("#text1").show();
            $("#text2").css('display','none');
        } else if ($(this).attr("id") == "radio2") {
            $("#text2").show();
        } else if(($("#text1").hide()) && ($("#text2").hide()))
        {
             $("#text3").show();
        }
    });