Hi all, I want to develop a survey app that has ten radio selects.
After people submit the survey, the data will be processing and then
output the result. I met a problem when I was trying to process the
data from the form. Here is the code:

forms.py: contains the survey questions.
QUESTION_ONE= (('4','Black',), ('3', 'Red',), ('2', 'Green',), ('1',
'Purple',))
lass SurveyForm(forms.Form):
    q1 = forms.ChoiceField(
        widget=forms.RadioSelect,                         # radio select
        label=u" 1. What's your prefered colour?",
        choices = QUESTION_ONE                     # four choices
    )

views.py
  def take_survey(request):
        if request.method=='POST':
                form = SurveyForm(request.POST)
                if form.is_valid():
                        p1 = form.cleaned_data['q1']    # get the result of 
input
               p = p1[0]                                        #get
the number
               if p>2:
                  return HttpResponseRedirect('a.html')       # if
user choose black or red, then redirect user to a.html

 i cannot get the correct result, but I do not know which step is
wrong. Hope someone could help me. Thank you.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to