By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,994 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,994 IT Pros & Developers. It's quick & easy.

Called function conditional testing (if) of form variables problem

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.