[jQuery] How do i "generify" this action to happen for every radio button with id=other
I have a form
On form I have several groups of radio buttons. Many (most) of these
groups of radio buttons has one in the group with a value of "other"
and an id of unique_id_other.
When a user selects "other" an input text field is shown and the other
radio button goes away. This is done via code such as the following:
[code]
// in IE you must use the click event, in other browsers change.
var evt = $.browser.msie ? "click" : "change";
$("#sample_other").hide();
$("input[@name='sample']").bind(evt, function(){
if ($("input[@name='sample']:checked").val() == 'other') {
$("#sample_other").show();
$("#edit-sample-other-wrapper").hide();
$(this).parents('div:eq(2)').find('.description').hide();
} else {
$("#sample_other").hide();
$("#edit-sample-other-wrapper").show();
$(this).parents('div:eq(3)').find('.description').show();
}
});
[/code]
Question is - how do I generify this, make it into a function such
that I don't have to write one of these blocks of code for every set
of radio buttons with an 'other' choice?
thanks
K
Currently I have a bunch of calls for each