Hi, I want to provide unique attributes to each radio button in a RadioSelect widget to integrate with several AJAX effects. Ideally the code produce would look something like this:
<ul> <li><label for="id_book_type_0"><input type="radio" id="id_book_type_0" value="all" name="book_type" onclick="checkStatus(1);"/> All books</label></li> <li><label for="id_book_type_1"><input type="radio" id="id_book_type_1" value="inprint" name="book_type" onclick="checkStatus(1);"/> In print books</label></li> <li><label for="id_book_type_2"><input type="radio" id="id_book_type_2" value="outofprint" name="book_type" onclick="checkStatus(1);" /> Out of print books</label></li> <li><label for="id_book_type_3"><input type="radio" id="id_book_type_3" value="outofprint" name="book_type" onclick="checkStatus(2);" /> Only these books</label></li> </ul> Basically, when the last radio button is selected, the JS code will enable another field with a list of books. That list would be disabled when one of the first 3 bullets are selected. I can't find a way to do this natively with newforms, but it seems like this would be a pretty common use case so I may be missing something. When I construct the form field, it looks like this: book_type = forms.ChoiceField( choices = BOOKCHOICES, widget=forms.RadioSelect(attrs={'onclick':'checkStatus(1)'}) ) And this makes the onclick attribute for every radio button the same. So, my questions are: 1. Can this be done natively with newforms? 2. If not, how have people solved this in the past (subclass the RadioSelect widget?) 3. Does this functionality make sense to include in newforms? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---