JQuery that handles multiple inputfields
I have this JQuery function:
<script>
$(function () {
$("#cspinner").spinner({
min: 5,
max: 15000,
step: 5,
start: 100,
numberFormat: "C"
});
});
</script>
which corresponds to this input field:
<input id="cspinner" name="cspinner" size="8" value="0" readonly="readonly" />
I am using JQuery UI controls, but my question is really around basic JQuery. Now This input field works fine with the JQuery function, however I am generating a collection of input fields which I want the JQuery function to work with.
How do I approach this?
I have no problems generating a collection of inputfields with their own unique id, but how do I make a function that can work generally on all of them instead of one. I don't want to generate the same amount of JQuery functions as the inputfields, that would be silly.
Can anyone help me with this challenge? Help is deeply appreciated.
Ideally I want the function to be able to deal with my dynamically generated inputfields:
<input id="cspinner[1]" name="cspinner" size="8" value="0" readonly="readonly" />
<input id="cspinner[2]" name="cspinner" size="8" value="0" readonly="readonly" />
<input id="cspinner[3]" name="cspinner" size="8" value="0" readonly="readonly" />
<input id="cspinner[4]" name="cspinner" size="8" value="0" readonly="readonly" />
...
<input id="cspinner[∞]" name="cspinner" size="8" value="0" readonly="readonly" />