How to store a variable in Javascript for different page accesses

I've written a javascript code to embed on my Google site (through Google Gadget Editor) It is a survey!

I would like to store a number, so every time another user access the page, they see the last user final result.

It is possible without using databases?

Thank you so very much in advance

Upvotes: 1

Views: 139

Answers (3)

Alex Reynolds
Alex Reynolds

Reputation: 6352

Yes. There's a few different routes. I think you could store the data you want in a file. Then have JS read the file to get the data. Could be XML. Then when the next survey is complete have JS add a new entry or overwrite the xml file. Hey don't downvote if you don't understand. You can use JS to make an AJAX call to get the php or have php do the original parse of the file. It is possible to do without a database as was the question.

Upvotes: -2

cuzzea
cuzzea

Reputation: 1535

No, you should try and find external storage, maybe use a free survey from other sites

Upvotes: 0

hvgotcodes
hvgotcodes

Reputation: 120198

No. HTTP is inherently stateless. You need to do something server side to push results like that to a web page.

If you are using javascript, you can keep a running count, but every time a user refreshes the page, the count gets reset. Plus, the count is local only to that browser. So if you wrote to a cookie, the count would only be available to that browser.

Upvotes: 3

Related Questions