vivekam8 Posted April 27, 2012 Share Posted April 27, 2012 I am very new to jquery and ajax. While googling (i wonder if "googling" is a dictionary word!!) for some code which enables to toggle between two divs using radio buttons, I stumbled upon this code. It is not working but I feel it is very close to being correct!! Can someone help me to correct this? Thanks in advance Your fan! <html> <head> <script type="text/javascript"> $(function() { $("[name=toggler]").click(function(){ $('.toHide').hide(); $("#blk-"+$(this).val()).show('slow'); }); }); </script> </head> <body> <label><input id="rdb1" type="radio" name="toggler" value="1" />Money</label> <label><input id="rdb2" type="radio" name="toggler" value="2" />Interest</label> <div id="blk-1" class="toHide" style="display:none"> money </div> <div id="blk-2" class="toHide" style="display:none"> interest </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/261680-toggle-a-div-using-radio-buttons/ Share on other sites More sharing options...
requinix Posted April 27, 2012 Share Posted April 27, 2012 Are you including the jQuery library somewhere? It's not in the code you posted. i wonder if "googling" is a dictionary word!! Yep. Quote Link to comment https://forums.phpfreaks.com/topic/261680-toggle-a-div-using-radio-buttons/#findComment-1341008 Share on other sites More sharing options...
trq Posted April 27, 2012 Share Posted April 27, 2012 While your googling things, you should google *ajax* as your code doesn't use any at all. Quote Link to comment https://forums.phpfreaks.com/topic/261680-toggle-a-div-using-radio-buttons/#findComment-1341081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.