Counter + 1 2 3 (...) n

Hi,

I was trying to create a counter that starts with + and OnClick value changes to 1, and then on next click the number raises by 1.

This is my setup:

How can I change the setup to get rid of the + in front of the 1 after the first click? ( from “+1” to “1”)

Here’s what I’m pretty sure is happening. When you first click, LVAR1 is equal to +. When you attempt to add 1 to that it concatenates them since + is a string that can’t be treated as a number. So the result is +1. When you click the second time, LVAR1 is equal to +1 which can be treated as a number, positive one. So instead of concatenating them Axure will treat both sides of the plus as numbers and add them. From here on out it works as expected.

Try this instead:

[[(lvar1 + 1).replace('+','')]]
1 Like

I would not use LVAR, instead I’d throw global variable and set default to 0 , which is always number :slight_smile:

Thanks guys, that worked out!