You can't do it simply with a variable. Each http request is a separate
run of the server script, so no variable values can be carried over.
Even if they could be, you can have multiple, separate users doing this
simultaneously, so there would be no way to know which 'original
setting' should be associated with each 'subsequent submission'.
Basically, there are a few approaches.
1. Use a cookie
Not difficult (just be sure you set the cookie value before ANY other
output from the script. I do all my output through a library - I never
do any direct "put"s from an on-rev script - that way I can detect if a
"putcookie" attempt will fail because some output has already happened.)
2. Use session data. Maybe slightly preferable if there is any other
session data around, otherwise not much to choose against cookie.
3. Hidden value in the form data. (I think this or 3a is the best answer).
3a. Hidden value slightly different in the form data (e.g. correct
answer + 1)
3b hidden token in the form: keep a file/database of taken:value pairs,
where the token is random, and the value is the required answer, put the
token into the hidden field in the form. More secure I guess -
equivalent to a cookie, but limited in 'cost' to the single response.
4. Guessing :-)
keep a file of ip addr + time + correct answer, and then match ip
address of the incoming value from the user to recent answers. Should be
OK for low-turnover sites, esp. if you make the range of possible values
large enough.
5....
I'm sure there are others I don't know about or haven't thought of right
now.
-- Alex.
On 01/09/2013 09:04, Scott Rossi wrote:
Right, I noticed the inclusion of the answer, but it's obscured which
helps. Is a cookie really the only way to do this without adding the
answer to the page?
My thought was the answer value would get stored in an onrev variable when
the question is generated, and the evaluation would be able to operate on
that same variable. But as I said, I couldn't figure out how/if this was
possible.
Best Regards,
Scott Rossi
Creative Director
Tactile Media, UX/UI Design
On 9/1/13 12:55 AM, "Alex Tweedly" <a...@tweedly.net> wrote:
Yes, Sarah's example works nicely. (Her form puts the correct answer
into the form as a hidden value, so it too is returned when the user
submits the form; that's easier than the alternative of storing in a
file/database, and using a cookie/session data to identify the user and
retrieve the stored value for comparison).
If you feel extra-paranoid (I can imagine there being robots which will
simply return all hidden values in their auto-responses), then instead
of putting the correct answer into the hidden field, you put in say
"answer+1"
-- Alex.
On 01/09/2013 08:14, Scott Rossi wrote:
Actually, I found some example scripts on Sarah Reichelt's site that
look
like they may work.
http://www.troz.net/onrev/
Regards,
Scott Rossi
Creative Director
Tactile Media, UX/UI Design
Recently I wrote:
Anyone know if it's possible for an onrev script on a page to share its
value with another onrev script?
I'm trying to a form validation of sorts using an onrev script, where
part
of the form is dynamically generated by another script. The content
is a
question like "What is 1 + 1?" which is created using some random
elements. Is there some way to make the validation script aware of the
dynamically generated question content without including the answer in
the
page?
Thanks & Regards,
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode