Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have checkboxes where a user can select some checkboxes. the data is from a database. for example there are 10 checkboxes and a user select 4 checkboxes - so that is 40% is filled in. But how to show that in a progress bar.

I have this:

css:

CSS
.default {
    background: #292929;
    border: 1px solid #111;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 0 5px #333;
}
.default div {
    background-color: #1a82f7;
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0099FF), to(#1a82f7));
    background: -webkit-linear-gradient(top, #0099FF, #1a82f7);
    background: -moz-linear-gradient(top, #0099FF, #1a82f7);
    background: -ms-linear-gradient(top, #0099FF, #1a82f7);
    background: -o-linear-gradient(top, #0099FF, #1a82f7);
}



and jquery:

C#
function progressBar(percent, $element) {
    var progressBarWidth = percent * $element.width() / 100;
    $element.find('div').animate({ width: progressBarWidth }, 500).html(percent + "% ");
}


and then in the cshtml file:

C#
$(document).ready(function () {
           progressBar(50, $('#progressBar'));

       });



but you can see that is hardcoded(it shows always 50%). but so how to make it dynamic that it response on the values of the database.

Thank you!!
Posted

1 solution

Check out this one.

http://www.dotnetcurry.com/showarticle.aspx?ID=384[^]

I think it will solve your problem.
 
Share this answer
 
Comments
[no name] 21-Mar-15 2:19am    
Thank you for your answare, I will look at it
Arkadeep De 21-Mar-15 2:44am    
you welcome
[no name] 21-Mar-15 9:10am    
I have looked at it. But this is a prgress bar. This is not what I mean. I mean checkboxes and then the user can see how many checkboxes are checked

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900