I made a progress bar with the bootstrap. Then every time something is filled in the table a certain percentage more is inserted in the bar. The data that is inserted into the table comes from an API, so it does this automatically. I did it as follows:
function Progresso(){
var progressTest = document.querySelector('.info-nome');
var teste = progressTest.textContent || progressTest.innerText;
var cont = teste.length;
if (cont > 0) {
var Porc = document.getElementById('progresso_Id').style.width = "5%";
}
}
If the class that comes from api that contains the name is filled, that is, it is more than 0, it will insert 5% in the progress bar. But unfortunately it does not work the way I want it to. Another example of the rest of my code:
function Prog() {
var progressTest = document.querySelector('.info-cpf');
var teste = progressTest.textContent || progressTest.innerText;
var cont = teste.length;
if (cont > 0) {
var Porc = document.getElementById('progresso_Id').style.width = "10%";
}
}
That is, he is not adding + 5%, but rather 10%, so if the name is not entered and cpf is yes, it is already going to 10%
How can I insert + 5% and not change the width of the progress bar? The progress bar is by bootstrap
<div class="container conteudo">
<div class="row nospace">
<div class="progress">
<div class="progress-bar progress-bar-danger active progress-bar-striped progresso" id="progresso_Id" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width:0%">
<span class="sr-only">0%</span>
</div>
</div>
</div>
</div>
And how can you do this in pure javascript? If possible, I would also like to know how I put it to show how much percent already has in the bar for the user to see
API:
var endereco = 'http://api';
$.ajax({
url: endereco,
crossDomain: true,
complete: function(res){
var meuJSON = JSON.parse(res.responseText);
var a = [meuJSON];
a.forEach(function(element) {
console.log(element);
for (var i = 0; i < 1; i++) {
element[i]
var adiciona = element;
AdicionaNome(adiciona[1]);
AdicionaCPF(adiciona[1]);
AdicionaProduto(adiciona[1]);
AdicionaCidade(adiciona[1]);
AdicionaCodigoProduto(adiciona[1]);
AdicionaCodigoCliente(adiciona[1]);
AdicionaStatus(adiciona[1]);
AdicionaEntPrevista(adiciona[1]);
AdicionaEntregaProgramada(adiciona[1]);