If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Help with tally script

Hello,

I am trying to do up a script for my mum so I can turn it into an app for her android. This app would allow her to keep track of my chores around the house and the value of each chore (also the chores I don't do (subtracting).

It tallys the jobs I do with a money amount. The code below is one I have borrowed and done some editing on, but I am stuck now.

It adds up to give a total which is nice, but I would also like a number tally next to the chore. For example with dishes there should be a box next to dishes that gives the number of times I have done the dishes, which would increase every time the dishes are done.

If you want to store data from one page visit to another (such as the total number of times you have washed the dishes) you will need to use a cookie or local storage.

BTW, when posting here please help us to help you by making it easier to copy, test and debug your scripts by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.

It's unthinkable that racing might not go ahead today because of the weather. Although obviously it might not. - bv Racing commentator, BBC Radio 3.

Last edited by Philip M; 04-24-2013 at 09:05 AM.

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

I think you need to specify<!DOCTYPE html>
or use <input type = "button"

But I cannot get the local storage to work - in any case it will not work in IE when run locally (not on line).

It works fine on my computers.
My localstorage tests are not being done from a server at this time, but in the past they work well also.
I'm using an older version of Safari on the iMac and FF on a PC.
I do not currently have access to MSIE. Will need to test in evening.

I believe the mistake I made was in checking for the localstorage value == 'undefined', instead of just undefined.
Anyway, made an additional button to clear total if it still shows NaN in display.
Let me know if you still have an error with the 'rake leaves' button adding to the tally total.

You are obviously right as I tried it using MSIE V10.0 and I get the annoying (to paraphrase),
"...Is it OK to run on your own computer since you might be too dumb to know you started the program yourself..." message.

Since it is such a small storage amount, is your suggestion to recode it to use cookies instead of localstorage commands?

Also, where do you find your information about not being able to use in MSIE on local file:/// ???

Since it is such a small storage amount, is your suggestion to recode it to use cookies instead of localstorage commands?

Also, where do you find your information about not being able to use in MSIE on local file:/// ???

Personally I would use a cookie. I know that local storage is fashionable, but at least cookies work in all browsers. I do not really see any reason to use local storage unless the amount of data to be stored is large. Another weakness of local storage is that it doesn’t work cross-browser. In other words, data written to local storage by a page running in Firefox can’t be read by the same page running in Chrome, and vice versa. This could be a significant defect.

Personally I would use a cookie. I know that local storage is fashionable, but at least cookies work in all browsers. I do not really see any reason to use local storage unless the amount of data to be stored is large. Another weakness of local storage is that it doesn’t work cross-browser. In other words, data written to local storage by a page running in Firefox can’t be read by the same page running in Chrome, and vice versa. This could be a significant defect.

localStorage works in all browser since IE8, no compat concerns there. The file:// mode in IE, which js is not really meant for, is the only "exception" i know of. Many Many people block cookies using an add-on, and IE7 is < 1%, so it would not suprise me if localStorage is actually more reliable than cookies in the real world. A good litmus? Advertisers use it.

I don't get the point about cookies: IE won't read chrome's cookies any better than it would its localStorage, no disadvantage there.
considering the performance hits that cookies bestow, i avoid them by any means i can.