Foros del Web » Programando para Internet » Javascript »

Problemas con el formato de fecha en javascript

Estas en el tema de Problemas con el formato de fecha en javascript en el foro de Javascript en Foros del Web. Buenas tardes, Tengo un problema con la forma en como el javascript me muestra los numeros decimales, porque a veces me lo muestra en el ...
  #1 (permalink)  
Antiguo 19/05/2011, 13:44
 
Fecha de Ingreso: octubre-2006
Mensajes: 8
Antigüedad: 17 años, 6 meses
Puntos: 0
Problemas con el formato de fecha en javascript

Buenas tardes,

Tengo un problema con la forma en como el javascript me muestra los numeros decimales, porque a veces me lo muestra en el siguiente formato xx.xx pero otras veces lo muestra en el siguiente formato xx.xx. (es decir le coloca un punto al final

Así es como lo llamo:

Código PHP:
Ver original
  1. <input
  2.                             id="cantidad_verif_<?php echo $actaSaldo->getItem();?>"
  3.                             name="cantidad_verif[]"
  4.                             type="text"
  5.                             value="<?php  echo $actaSaldo->getCantidadVerif();?>"
  6.                             class="number"
  7.                             onkeypress="changeItem(this, event)"
  8.                             onfocus="tab_<?php echo $actaSaldo->getItem();?> = (typeof(tab_<?php echo $actaSaldo->getItem();?>) == 'undefined')? tab_<?php echo $actaSaldo->getItem();?> = new Temporales(<?php echo $actaSaldo->getItem();?>) : tab_<?php echo $actaSaldo->getItem();?>;"
  9.                             onblur="tab_<?php echo $actaSaldo->getItem();?>.verificar(<?php echo $actaSaldo->getItem();?>)"
  10.                             size="8"
  11.                             style="color:#000"
  12.                         >

Y esta es la función que manipula la data que recibe:
Código Javascript:
Ver original
  1. Temporales = function(item){
  2.     this.cantidad       = parseFloat($('cantidad_verif_'+item).value);
  3.     this.cantidad_dec   = parseFloat($('cantidad_'+item).value);
  4.     this.precio         = parseFloat($('precio_verif_'+item).value);
  5.     this.precio_dec     = parseFloat($('precio_'+item).value);
  6.     this.totales = new CalcularTotales();
  7.     this.setCantidad = function(cantidad){
  8.         this.cantidad = cantidad;
  9.     }
  10.     this.getCantidad = function(){
  11.         return this.cantidad;
  12.     }
  13.     this.setPrecio = function(precio){
  14.         this.precio = precio;
  15.     }
  16.     this.getPrecio = function(){
  17.         return this.precio;
  18.     }
  19.     this.setCantidadDec = function(cantidad){
  20.         this.cantidad_dec = cantidad;
  21.     }
  22.     this.getCantidadDec = function(){
  23.         return this.cantidad_dec;
  24.     }
  25.     this.setPrecioDec = function(precio){
  26.         this.precio_dec = precio;
  27.     }
  28.     this.getPrecioDec = function(){
  29.         return this.precio_dec;
  30.     }
  31.     this.verificar = function(item){
  32.         var cantidad      = $('cantidad_verif_'+item);
  33.         var precio        = $('precio_verif_'+item);
  34.         cantidad.value = (isNaN(cantidad.value))? 0 : cantidad.value ;
  35.         precio.value = (isNaN(precio.value))? 0 : precio.value ;
  36.        
  37.         if(parseFloat(cantidad.value) < 0 || parseFloat(cantidad.value) > this.getCantidadDec() || parseFloat(cantidad.value) ==='' || isNaN(parseFloat(cantidad.value))){
  38.             cantidad.value = this.getCantidadDec();
  39.         }
  40.        
  41.         if( parseFloat(precio.value) < 0 || parseFloat(precio.value) > this.getPrecioDec()  || parseFloat(precio.value) ==='' || isNaN(parseFloat(precio.value))){
  42.             precio.value = this.getPrecioDec();
  43.         }
  44.         if(this.getCantidadDec() != cantidad.value || this.getPrecioDec() != precio.value){
  45.             $('modificado_'+item).value = 1;
  46.             $('observacion_'+item).style.visibility="visible";
  47.             var array_tds = $('observacion_'+item).parentNode.parentNode.childNodes;
  48.             for(t = 0; t< array_tds.length; t++){
  49.                 td_seleccionado = array_tds[t];
  50.                 if(td_seleccionado.tagName){
  51.                     td_seleccionado.style.background = "#FFF9A8";
  52.                 }
  53.  
  54.             }
  55.             this.totales.calcular();
  56.            
  57.             return true;
  58.         }
  59.         else{
  60.             $('observacion_'+item).style.visibility="hidden";
  61.             $('observacion_'+item).selectedIndex = 0;
  62.             var array_tds = $('observacion_'+item).parentNode.parentNode.childNodes;
  63.             for(t = 0; t< array_tds.length; t++){
  64.                 td_seleccionado = array_tds[t];
  65.                 if(td_seleccionado.tagName){
  66.                     td_seleccionado.style.background = "#FFFFFF";
  67.                 }
  68.  
  69.             }
  70.             this.totales.calcular();
  71.             $('modificado_'+item).value = 0;
  72.             if(this.getCantidad() != cantidad.value || this.getPrecio() != precio.value){
  73.                 $('modificado_'+item).value = 1;
  74.             }
  75.             return false;
  76.         }
  77.     }
  78. }

Etiquetas: fecha, formato
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:03.