www.webdeveloper.com
Results 1 to 2 of 2

Thread: Radio Button + Change Website with Javascript

  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Radio Button + Change Website with Javascript

    Hey guys,

    I'm absolutely newb when it comes to using javascript, so I'll need major help if you care to dish it

    So I have a website where I can change some portion of it based on the pressing of a radio button:

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    
    
    <script type="text/javascript">  
    $(document).ready(function()
    {
    $('.MyDiv').hide();
    $('#divguy').show();
    
    $('input[name="myRadio"]').click(function(){
    var selected = $(this).val();
    $('.MyDiv').slideUp();
    $('#'+selected).slideDown();
    });
    
    });
    
    </script>
    
    
    <p><b> I want to see a :</b>
    
    <input type="radio" name="myRadio" value="divfemaledog" checked />Female Dog &nbsp;&nbsp;
    <input type="radio" name="myRadio" value="divmaledog" />Male Dog
    </p>
    
    <div id="divfemaledog" class="MyDiv" style="background-color:#ADDFFF; height: 300px; width:600px;";>
    <h1>Images of Female Dogs!!</h1>
    </div>
    
    <div id="divmaledog" class="MyDiv"  style="background-color:#F9B7FF; height: 300px; width:600px;">
    <h1>Images of Male Dogs!!</h1>
    </div>
    So all that works fine and dandy..but is there a way of using more radio/checkbox buttons to have more variables?

    For instance, can I have a page that changes based on three variables: Female/Male Shorthaired/Longhaired Dog/Cat/Rabbit?

    In this way, the default image would be Female shorthaired dogs, but someone can press male, and it would should male shorthaired dogs, and then someone could press rabbit and it would show male shorthaired rabbits?

    Does this make sense? And is it possible?

    Thanks

  2. #2
    Join Date
    Feb 2011
    Posts
    2
    Does the silence mean there is no way to do this?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles