Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently working on a YUI Progress Bar for a profile page on a portal, and have run into trouble getting the bar to update after an AJAX call.

This is the initial code in the view.jsp which renders the progress bar on page load;
var pb = new YAHOO.widget.ProgressBar({value:<c:out value="${percentage}" />,minValue:0,maxValue:100}).render('divid');

When users edit a field on the page, there is an AJAX call to update the fields and also the percentage value of profile completion.

There is a function that is also run here, which should update the progress bar, but it isn't working.
C#
function() {
          items = this.get('responseData');
          var percentage = items[0].value;
          document.getElementById('percent').innerHTML = percentage + '%';
          var element = document.getElementById("divid");
          element.innerHTML = "";
          renderProgressBar(percentage, "divid");
       }

function renderProgressBar(percentage, id){
alert(percentage);

var pb = new YAHOO.widget.ProgressBar({value:10, minValue:0, maxValue:100}).render(id);
pb.set('value', percentage);

}


The percentage value is being updated, as I'm updating the innerHTML of the 'percent' div, and it is correctly updating.

I also display an alert in the renderProgressBar to make sure the value is correct there also.

When it comes to updating the bar however, it just doesn't work, the value is always null or empty.

Any ideas?

I also tried to hardcode adding an entirely new progress bar after clearing the div tag, here is the output when the page is rendered;
YAHOO.widget.ProgressBar({value:, minValue:0, maxValue:100}).render('divid');

As you can see, the value is empty.
Posted

1 solution

try to use this

document.getElementById('<%=percent.ClientID%>')


hope it helps!
 
Share this answer
 

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