Having issues with JQuery progress bar
Posted
by Roland
on Stack Overflow
See other posts from Stack Overflow
or by Roland
Published on 2010-05-24T07:48:35Z
Indexed on
2010/05/24
7:51 UTC
Read the original article
Hit count: 259
I'm busy creating a poll but am experiencing issues creating a progress bar for a poll using jquery, thus I have a couple of options and then when the page loads the div tags should increase in width, but it's not doing anything only if I have on option in the poll
code
<?php foreach($votes as $v): ?>
<div><?php echo $v['name'].':'; ?></div>
<div>
<?php echo 'Votes: '.$v['num'].' | '.$v['percent'].'%'; ?>
</div>
<script type="text/javascript">
load(<?=$v['name']?>,<?=$v['percent']?>);
</script>
<div style="width:100%; height:10px; background-color:#effdff;"><div id="<?=$v['name']?>" style=" height:10px; background-color:#ff0000;"></div></div>
<br />
<?php endforeach; ?>
<?php if(!empty($loginMsg)): ?>
<?php echo $loginMsg; ?><br />
<?php endif; ?>
Votes: <?php echo $totalVotes+$totalComments; ?> | Comments: <?php echo $totalComments ?>
<script type="text/javascript">
var interval='';
var progress = 0;
function load(id,val){
alert(id);
if (interval=="") {
interval=window.setInterval("display('"+id+"','"+val+"')",200);
}
}
function display(id,val) {
progress += 1;
if(progress == val){
window.clearInterval(interval)
interval = '';
progress = 0;
}
$("#"+id).css("width",progress+'%');
}
</script>
© Stack Overflow or respective owner