try this $('select').change(function(){ alert(this.value); }).change();
and to 'select' is better you use field ID otherwise all select field in you html will trigger this event. On Tue, May 7, 2013 at 2:14 AM, Fatih Tiryakioglu <fatih...@gmail.com>wrote: > Hi all, > > I have a jquery js code in a template like that: > > <script type="text/javascript"> > jQuery(document).ready(function(){ > jQuery("select").change(function(){ > var str = $('select option:selected').text(); > alert(str); > }); > });</script> > > and, a select form which is handled by the js code above: > > class GrupEklemeFormu(forms.Form): > GORL = ( > (1, ("Global")), > (2, ("Lokal")), > ) > g_or_l = forms.ChoiceField(choices=GORL) > > When I select Global or Local in the page, str becomes "GlobalGlobal" or > "GlobalLokal". What is the reason for that? How can I get rid of the error. > Thanks.. > > -- > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Anderson Dias Borges Senior Analyst Developer Tu cumprirás o desejo do meu coração se eu Te buscar... I can't see but I'll take my chances To hear You call my name -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.