views:

703

answers:

2

hi. I have search all over google for this and nothing. I am going off what i stared and found.

I have multiply radio buttons that i need to change a corresponding DIV when checked. I need to have the value free so and onlclick command would be better. PS: if i can have it fxfade instead of slideup and down it would help too.

buttons

  <input type="radio" name="myRadio" value="myDiv_1" />MyDiv2<br />
    <input type="radio" name="myRadio" value="myDiv_2" />MyDiv3<br />
    <input type="radio" name="myRadio" value="myDiv_3" />MyDiv4<br />

div's

<div id="myDiv_1" class="MyDiv">Div number 1!</div>
<div id="myDiv_2" class="MyDiv">Div number 2!</div>
<div id="myDiv_3" class="MyDiv">Div number 3!</div>

code i have so far

    <script type="text/javascript">
$(document).ready(function(){

    $('.MyDiv').hide();

    $('input[name="myRadio"]').change(function(){
        var selected = $(this).val();
        $('.MyDiv').slideUp();
        $('#'+selected).slideDown();
    });

});
</script>
A: 

Is your code not working? Your slideUp() and slideDown() will occur at the same time, so you might want to use a callback (and here with fading which I think you want):

$('input[name="myRadio"]').click(function() {
    var selected = $(this).val();
    $('.MyDiv').fadeOut("slow",function() {
        $('#' + selected).fadeIn("slow");
    });
});
carillonator
need the value="" free to be able to add that color name to the shopping cart. in terms of the fade effect - i need the displayed div to fade out and then fade in the new div. as you can see they are fading in and out weird -http://www.shadescases.com/shadescases_new/products/testfade.html
Ryan Ferreira
what/where do you mean that value="" needs to be free? I got a Forbidden (permissions) error when I tried your link.
carillonator
A: 

thanks a lot for your code..

Richa