_hyperscript
_hyperscript copied to clipboard
Increment/Decrement uses the value of the first input
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>
I can also confirm i have a similar issue.
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
@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/
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
I landed only on one solution https://jsfiddle.net/eu29kdtr/ Send an event to elements and on that event on each element do something
Also accidentally found yet another way on click repeat for x in <input/> increment the value of x end
definitely a bug, will try to fix for the next release