basic web calculator

Q&A's, tips, howto's

basic web calculator

Postby joejoe » Thu Oct 13, 2016 10:01 pm

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)
joejoe
 
Posts: 158
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Re: basic web calculator

Postby TedWalther » Fri Oct 14, 2016 8:23 pm

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

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

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.
TedWalther
 
Posts: 605
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: basic web calculator

Postby joejoe » Fri Oct 14, 2016 8:45 pm

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!
joejoe
 
Posts: 158
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest