Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Bootstrap 3 progress bar, set width with javascript object value

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #192905
    tarnos12
    Participant

    Hello, I am trying to set progress bar width with percentage value min 0% max 100%, using an object, my object value is between 0 and 100.

    var divArray = document.getElementById(‘progressBar’);
    divArray.style.width = ‘22%’;

    This will work because I set width with a number 22%, and it set width to 22%, how can I achieve this with something like:

    divArray.style.width = myObj.player.experience;

    where player.experience is equal to = 22… I will try to set my experience to a string like ‘22%’ that might work, but I am not sure about that.

    @EDIT:

    Hey, I found a solution, for someone who might need it, here it is:

    divArray.style.width = ((exppercent2) + ‘%’);

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.