• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 124
  • Last Modified:

how to increment an onclick argument or is it a parameter?

In my html, if I have:

<script>var index = 1</script>
 <input type="button" value="Add One" onclick="addOneFunction(index)">

how can I increment the index value by 1 each time the button is clicked?
0
Gary Samuels
Asked:
Gary Samuels
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
<input type="button" value="Add One" onclick="addOneFunction(++index)">

or

<input type="button" value="Add One" onclick="addOneFunction(index++)">
0
 
leakim971PluritechnicianCommented:
I think you want the second which add 1 after passing it, not before
0
 
Gary SamuelsPlant ManagerAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now