As far as I know, the only way to change anything in html is using ajax.
On Saturday, 30 June 2012 13:04:06 UTC-3, Ash Courchene wrote:
>
> Hi Everyone,
>
> Im trying to put together this number guessing "game" together as part of
> a larger "text-based adventure game" app (the final project of Learn Python
> the Hard Way), and am wondering if there was a way change a variable in my
> application without the page being refreshed. I understand that html files
> are "stateless", so that may be affecting why when I write this code (or a
> variation of) below, it doesn't work.
>
> num, guess = session.room.generate() # a function used to generate a
> random number for the user to guess and how many tries they get.
> if form.action != num: # form.action is user input
> guess -= 1
> session.room.output = "BZZT. Access Denied. You have %d tries
> left." % guess # session.room.output is what the user sees as a result of
> their actions
> if guess == 0:
> session.room = session.room.go('*') # moves user to a game
> over screen, pretty much.
> elif form.action == num:
> session.room = session.room.go('next')
> ....
>
> I've thought about using session variables, but even after i set one up
> (and I don't even know if i did it correctly), the result is the same.
> session.room.output always stays at nine. and the user never gets out of
> that "room". I don't know if this makes much sense...
> But does anyone know how I can achieve getting the variable "guess" down
> to zero if the user doesn't input the correct number? Thanks.
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/webpy/-/SwmExSfp54QJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.