title: Ajax replace number dot to comma not working
body: <p>I have a function that obtains numbers from inputs fields, the numbers are with comma instead of dots on decimals (123,5), so what i do is conver them with replace to make the calculations and then replace them again to comma to display the results but it is giving me problems in the last replace, which is in an ajax return</p>
  
  <p>The error: <code>"ncaught TypeError: subt1.replace is not a function at XMLHttpRequest.ajax.onreadystatechange"</code></p>
  
  <p>I get the calculations right but when i try to convert it to comma decimal doesnt work
  I supose is because the typing but i dont get it right</p>
  
  <p>heres my code</p>
  
  <pre><code>function updateCarrito(id,precio,moneda) {
  
      var cant=document.getElementsByName("carrito_cantidad_"+id)[0].value;
  
      var ajax=nuevoAjax();
  
      var contenedor=parent.document.getElementById('iconCarrito');
  
      var subt1=document.getElementById('cantidad_compra1_'+id).value;
  
      if (moneda==1){
          var tot=document.getElementById('total_compra_pesos').value;
      }else{
          var tot=document.getElementById('total_compra_dolares').value;
      }
  
      subt1 = subt1.replace(/\./g, '').replace(',', '.');
      tot = tot.replace(/\./g, '').replace(',', '.');
  
      ajax.open("GET", "http://www.somestuff.com?req=updateCarrito&amp;id="+id+"&amp;cant="+cant+"&amp;precio="+precio,true);
      ajax.onreadystatechange=function() {
  
          if (ajax.readyState==4) {
              contenedor.innerHTML = ajax.responseText;
  
                  tot=(tot-subt1);
                  subt1=(precio*cant);
                  subt1 = subt1.replace('.', ',');
  
                  document.getElementById('cantidad_compra1_'+id).value=subt1;
  
                  tot=(tot+subt1);
                  tot = tot.replace('.', ',');
  
                  if (moneda==1){
                      document.getElementById('total_compra_pesos').value=tot;
                      document.getElementById('total_compra_pesos2').value=tot;
                  }else{
                      document.getElementById('total_compra_dolares').value=tot;
                      document.getElementById('total_compra_dolares2').value=tot;
                  }
  
          } 
      };
  
      ajax.send(null);
  
  }
  </code></pre>