How to round percentage? [closed]

-1

I would need the function below in .asp, I have no idea of the language, can anyone help?

I did this in javascript, below:

 function limparClasse(classe) {
 var elementos = document.querySelectorAll('.' + classe);
 for (var i = 0; i < elementos.length; i++) 
 elementos[i].innerHTML = elementos[i].innerHTML.replace(/,.*%/, "%");
 }

     window.onload="limparClasse('vtex-cpShow')"


 <span class="desconto-de vtex-cpSave  vtex-cpShow ">30.0 % OFF /* ESTE VALOR É GERADO PELO SISTEMA */</span>

An example in JsFiddle link

    
asked by anonymous 30.04.2014 / 17:54

1 answer

2

Normally calculate the percentage in ASP and use Round to round.

  

Example 1

<%

    response.write(Round(24.13278) & "<br />")
    response.write(Round(24.75122))

%>

Result:

24
25
  

Example 2

Rounding, maintaining 2 decimal places:

<%

    response.write(Round(24.13278,2))

%>

Result:

24.13

VBScript Round Function

    
12.05.2014 / 15:34