I am using JQuery spinner control on my web form. But it's initial value is not getting set. I am using IE9 + VS2010
Here is the code I have written in my common function. I call this function at run time and send parameters accordingly.
function(spinnerid, minval, maxval, initvalue, step) {
$("#" + spinnerid).spinner({ min: minval, max: maxval, increment: step, value: initvalue });
}
These are the libraries I use:
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
And this is the HTML code:
<input type="text" id="income" class="income" />
I don't know why the value option isn't working as documented. I've tried it myself and have the same problem. This will solve your issue though...
function setSpinner(spinnerid, minval, maxval, initvalue) {
$("#" + spinnerid).spinner({ min: minval, max: maxval }).val(initvalue);
}
I just added the val()
at the end to set the initial value. (I also added a function name, just because you missed it in your question. Call it what you need.)
There is no value
option during spinner
construction. You will have to use .val()
just like @Archer suggested.
Also, another issue is increment
, you mean incremental
. Or step
if you're trying to pass in a number. Check the linked documentation.
So your function becomes
function(spinnerId, min, max, init, step) {
$('#' + spinnerId)
.spinner({min:min, max:max, incremental /*or 'step'?*/:step})
.val(init)
;
}
ref: spinner API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With