JavaScript Passing a value from a button in javascript to a function that creates a localStorage variable passing value from html to python,passing value from child

I have a survey web app at work to collect data from customers. I'm trying to convert a dozen different functions (one for each option) into one simple function. The "votes" are stored as localStorage variables so that the survey can be reopened each day without losing data. Here is what I have:

<script>

function vote(choice)
{
   if (localStorage.choice)
   {
      localStorage.choice=Number(localStorage.choice)+1;
   }
   else
   {
      localStorage.choice=1;
   }
   alert("Thanks for your input!  Have a nice day");
}

</script>

And then I have buttons in the body that look like this:

<li class="li" onClick="vote(a);">choice 1</li>
<li class="li" onClick="vote(b);">choice 2</li>
<li class="li" onClick="vote(c);">choice 3</li>

Functions work just fine if I have separate ones for each, what am I doing wrong to pass the letters into new localStorage variables?

Answer:1

I have an unordered list called test <ul id='test'></ul> it is dynamically populated with data via ajax. Each item 'li' is a div containing 'p' paragraphs. Each paragraph contains some ...

I have an unordered list called test <ul id='test'></ul> it is dynamically populated with data via ajax. Each item 'li' is a div containing 'p' paragraphs. Each paragraph contains some ...

I am trying to port a program from python (using OpenCV) to javascript/html, which generates a video where pixel colour are determined by a random function of its coordinates and its frame number. I ...

I am trying to port a program from python (using OpenCV) to javascript/html, which generates a video where pixel colour are determined by a random function of its coordinates and its frame number. I ...

I was having and bizarre error and I just want to understand why. I was getting a 'bad route' return from my css and Javascript files. As it turns all my paths were correct but the problem was caused ...

I was having and bizarre error and I just want to understand why. I was getting a 'bad route' return from my css and Javascript files. As it turns all my paths were correct but the problem was caused ...

In the following piece of code store.nextId and store.cache is used in the add method. I was wondering why not this? var store = { nextId: 1, cache: {}, add: function(fn) { if (!fn.id) { ...

In the following piece of code store.nextId and store.cache is used in the add method. I was wondering why not this? var store = { nextId: 1, cache: {}, add: function(fn) { if (!fn.id) { ...