Called function conditional testing (if) of form variables problem

E

Eduardo Biano

Hi,

I have a problem making conditional testing (if) of a
form variable "ans01"(refer generated error). When the
form variable is tested (if) by a called function
(foo) the value of "ans01" is not properly
represented.


def foo(request):
ans01 = request.get_form_var("ans01")
if ans01 == 4:
ans_1 = 1
return ans_1

The browser returns a blank screen or ans_1 is blank.
I tried to "return ans01" and the browser returned the
number 4. I am quiet sure of the above code and
searched python resources but found no solution.
Please help. Thank you in advance.

**************************
Below is a generated error to check the contents of
submitted form.
___________________________
...................
NameError: ...................

Form:
ans01 4
ans02 1
ans03 1
ans04 1
ans05 1
ans06 1
ans07 1
comments
headid 068A114
id 0646205
submit Submit
*******************************






__________________________________
Discover Yahoo!
Get on-the-go sports scores, stock quotes, news and more. Check it out!
http://discover.yahoo.com/mobile.html
 
L

Leif K-Brooks

Eduardo said:
def foo(request):
ans01 = request.get_form_var("ans01")
if ans01 == 4:
ans_1 = 1
return ans_1

ans01 will be a string ("4"), not an int (4).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,042
Members
48,769
Latest member
Clifft

Latest Threads

Top