basic web calculator

Started by joejoe, October 13, 2016, 03:01:33 PM

Previous topic - Next topic

joejoe

Hi,



I would like to create a basic web calculator using nL.



I would like to display three images which correspond to three different values (say 1, 2 and 3).



I would like to display a running total as the images are clicked on.



So, I would start with the value of 0.



I click on the first image (which has a value of 1), and the total updates to 1.

Then I click on the second image (which has a value of 2), and the total updates to 3.

Then I click on the third image (which has a value of 3), and the total updates to 6.

Then I click on the second image again, and the total updates to 8.

Etc..



And then I have a buton to clear.



Would anyone have pointers to get me going in the right place?



Specifically:



Do I need to use a web form to do this?

Do I need to use cookies or can I do this without cookies?



Thanks very much for any help to get me going in the right direction! :0)

TedWalther

#1
Maybe this will help you.  Don't think you need nL at all.  Here is some code that does something very similar, and should answer your questions:



http://reactor-core.org/baccarat.html">http://reactor-core.org/baccarat.html



If you want to use nL to store the clicks in a database or something, then use AJAX



http://www.newlisp.org/index.cgi?page=AJAX_and_newLISP">http://www.newlisp.org/index.cgi?page=AJAX_and_newLISP



The baccarat HTML page was generated by newLisp; I found it easier than typing all the html tags by hand. More accurate too.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

joejoe

#2
Hi Ted,



Thanks for the links and tips!



I am planning to have it be a lot more involved in the future, so I want to use nL because I know I can do everything with it.



I would rather not have to set up a database, but will if I must.



I was thinking to keep my tally in the url bar in a format something like this:



index.cgi?add=2&total=14



How is your baccarat game keeping tally? Is this with a db?



Thanks for your help Ted!