S
SolidJS2mo ago
snorbi

Rendering <input>s in <For>

How can I reference a dynamic number of <input>s to read their value? Thanks.
2 Replies
TaQuanMinhLong
TaQuanMinhLong2mo ago
how about get the ref of their wrapper and look for child refs to get all the values of the inputs? or you can just store everything in a store
const [refs, setRefs] = createStore([]);

<For each={inputs}>
{(input, idx) =>
<input ref={(ref) => setRefs(idx, ref)} />
}
</For>
const [refs, setRefs] = createStore([]);

<For each={inputs}>
{(input, idx) =>
<input ref={(ref) => setRefs(idx, ref)} />
}
</For>
deluksic
deluksic2mo ago
You can also subscribe to form submit where you get the FormData object This is useful when you want enter to submit behavior for example

Did you find this page helpful?