user2249899
user2249899

Reputation: 11

jQuery Progress bar value = variable

I want to make a jQuery progress bar where the value is that of an variable.

var mynumber = [whatever value]
$(function () {
    $("#progressbar").progressbar({
        value: mynumber
    });
});

I have searched on the net but can't find this anywhere. Thanks!

Upvotes: 0

Views: 1088

Answers (3)

Mohsen Safari
Mohsen Safari

Reputation: 6795

you need to link JQueryUI and JQuery, look at this code:

jsFiddle

HTML

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<div id="progressbar"></div>

JQuery

var number=37;
$( "#progressbar" ).progressbar({
  value: number
});

CSS

div{
    width:300px;
    height:30px;
}

Upvotes: 0

KeyNone
KeyNone

Reputation: 9150

As value can be of the type boolean or number (according to the jQuery API), you have to parse your variable into the specific type first:

var mynumber = [whatever value]
$(function () {
    $("#progressbar").progressbar({
        value: parseInt(mynumber, 10)
    });
});

Upvotes: 1

Choinek
Choinek

Reputation: 313

$("#progressbar").progressbar("option", "value", mynumber);

Upvotes: 0

Related Questions