# How to implement?

**URL:** <https://community.weweb.io/t/how-to-implement/4001>\
**Category:** Ask us anything\
**Created:** [August 24, 2023, 6:43am UTC](https://community.weweb.io/t/how-to-implement/4001 "2023-08-24T06:43:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [August 24, 2023, 6:43am UTC](https://community.weweb.io/t/how-to-implement/4001/1 "2023-08-24T06:43:04Z")

</div>

Give me a hint on how to do it. I don’t know what the correct name is, maybe counter).  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/f85c2f40e959f9e92bd74452cddfd677c512d429.png)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 24, 2023, 7:10am UTC](https://community.weweb.io/t/how-to-implement/4001/2 "2023-08-24T07:10:05Z")

</div>

Number field, two icons/buttons with workflow doing [number\_input.value]+1 and for subtraction is the same thing [number\_input.value]-1

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [August 24, 2023, 8:42am UTC](https://community.weweb.io/t/how-to-implement/4001/3 "2023-08-24T08:42:17Z")

</div>

Thanks, I did it.  
How do I limit it, so it doesn’t show less than 1?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 24, 2023, 8:44am UTC](https://community.weweb.io/t/how-to-implement/4001/4 "2023-08-24T08:44:48Z")

</div>

I’d go with some javascript formula like

```auto
([number_input.value] < 1) ? 1 : ([number_input.value] -1) 
//(is number is less than 1) ? if yes return 1 : (else return calculation)

```

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [August 24, 2023, 8:50am UTC](https://community.weweb.io/t/how-to-implement/4001/5 "2023-08-24T08:50:53Z")

</div>

> [@Broberto](#):
>
> ```auto
> ([number_input.value] < 1) ? 1 : ([number_input.value] -1) 
> //(is number is less than 1) ? if yes return 1 : (else return calculation)
> 
> ```

Here?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/3/3ad3f579c497436797ffcb93720cb7cac4eb28f9.png)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 24, 2023, 8:53am UTC](https://community.weweb.io/t/how-to-implement/4001/6 "2023-08-24T08:53:47Z")

</div>

I’d do it in the [-] icon workflow.

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [August 24, 2023, 10:25am UTC](https://community.weweb.io/t/how-to-implement/4001/7 "2023-08-24T10:25:33Z")

</div>

It went like this:

```auto
// Check if the variable value is less than 1
if ([number_input-value] < 1) {
  // If it is, return 1
  return 1;
} else {
  // If it's not, subtract 1 from the variable value and return the result
  return variables [number_input-value] - 1;
}

```

When I press “-” it becomes 0, when I press again it becomes 1.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 24, 2023, 10:45am UTC](https://community.weweb.io/t/how-to-implement/4001/8 "2023-08-24T10:45:34Z")

</div>

Check this out 🙂

Reference to the [Conditional (ternary) operator - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator)

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [August 24, 2023, 11:02am UTC](https://community.weweb.io/t/how-to-implement/4001/9 "2023-08-24T11:02:52Z")

</div>

Thank you very much for the explanation.
