I like the jquery library because your can change you code to be easier to read and look like this:
$('#elementId).change( function() {
if ($('input:radio[name=bar]:checked').val() == 'Option A') {
$('#element2).show();
}
})
I think you have use a uniqueID for each radio button while you can use the same name to create a radio button group. So the above code would probably look more like:
$('input:radio[name=foo]').change( function() {
if ($('input:radio[name=foo]:checked').val() == 'Option A') {
$('#element2).show();
}
})
Since you probably don't want this to run until the document is fully loaded It should look more like:
$(function() {
$('input:radio[name=foo]').change( function() {
if ($('input:radio[name=foo]:checked').val() == 'Option A') {
$('#element2).show();
}
})
})
svilla
Junior Poster in Training
88 posts since Aug 2010
Reputation Points: 27
Solved Threads: 27