Solved

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

Posted on 2014-10-14
3
103 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:garysamuels
  • 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:garysamuels
ID: 40380425
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now