Solved

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

Posted on 2014-10-14
3
111 Views
Last Modified: 2014-10-14
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
Comment
Question by:Gary Samuels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40380405
<input type="button" value="Add One" onclick="addOneFunction(++index)">

or

<input type="button" value="Add One" onclick="addOneFunction(index++)">
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40380409
I think you want the second which add 1 after passing it, not before
0
 

Author Closing Comment

by:Gary Samuels
ID: 40380425
Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question