Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment/Decrement uses the value of the first input #443

Open
storeman opened this issue Jun 27, 2023 · 7 comments
Open

Increment/Decrement uses the value of the first input #443

storeman opened this issue Jun 27, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@storeman
Copy link

On a click action and want to increment values of all inputs and reset the closest input to 0.

I created a fiddle to demonstrate:
https://jsfiddle.net/oj6c53bt/1/

I expect all inputs to have unique values at some point, but all values are synced with the first input of the selection.

<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://unpkg.com/[email protected]"></script>

</head>
<body>
    <span _="on click
          increment the value of <input/>
          set the value of the next <input/> to 0">Click me third</span>
    <input type="number"
          value="0"/>
  <br/>
    <span _="on click
          increment the value of <input/>
          set the value of the next <input/> to 0">Click me second</span>
    <input type="number"
          value="0"/>
  <br/>
    <span _="on click
          increment the value of <input/>
          set the value of the next <input/> to 0">Click me first</span>
    <input type="number"
          value="0"/>
</body>
</html>
@cipriano200
Copy link

I can also confirm i have a similar issue.

@FDiskas
Copy link
Contributor

FDiskas commented Aug 10, 2023

Thanks to your working example.
I also was struggling to get it working with input values. Maybe you will also find something useful from my example as return
https://jsfiddle.net/8d0jv1sw/

maybe you need to get the value before doing something.

get the (value of the next <input/>) as an Int increment it then set the value of the next <input/> to it

@storeman
Copy link
Author

@FDiskas I have a different use case. I want all the inputs to increase their own value. I've simplified the example, because my first example contained some noise

https://jsfiddle.net/rmuvcbx8/

@FDiskas
Copy link
Contributor

FDiskas commented Aug 11, 2023

There is a good candidate https://hyperscript.org/expressions/you/
on click tell <input/> increment value of yourself bet result is the same :/
will dig in to it

@FDiskas
Copy link
Contributor

FDiskas commented Aug 11, 2023

I landed only on one solution https://jsfiddle.net/eu29kdtr/
Send an event to elements and on that event on each element do something

@FDiskas
Copy link
Contributor

FDiskas commented Aug 11, 2023

Also accidentally found yet another way on click repeat for x in <input/> increment the value of x end

@1cg
Copy link
Contributor

1cg commented Oct 8, 2023

definitely a bug, will try to fix for the next release

@1cg 1cg added the bug Something isn't working label Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants