470,602 Members | 1,557 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,602 developers. It's quick & easy.

Called function conditional testing (if) of form variables problem

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
Jul 19 '05 #1
1 1318
Eduardo Biano wrote:
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).
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

28 posts views Thread by Benjamin Niemann | last post: by
18 posts views Thread by jimfortune | last post: by
64 posts views Thread by Morgan Cheng | last post: by
8 posts views Thread by Olov Johansson | last post: by
16 posts views Thread by Alan Jones | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.