Foros del Web » Programando para Internet » Javascript »

Script que funciona en Crome, Mozilla, Safari pero no en IE

Estas en el tema de Script que funciona en Crome, Mozilla, Safari pero no en IE en el foro de Javascript en Foros del Web. HOla a todos, tengo el siguiente script, que funciona en todos los navegadores menos en IE 9: La parte que no funciona es la que ...
  #1 (permalink)  
Antiguo 04/04/2012, 08:02
Avatar de msoto  
Fecha de Ingreso: abril-2012
Ubicación: Chile
Mensajes: 1
Antigüedad: 12 años
Puntos: 0
Pregunta Script que funciona en Crome, Mozilla, Safari pero no en IE

HOla a todos, tengo el siguiente script, que funciona en todos los navegadores menos en IE 9:

La parte que no funciona es la que valida que la cantidad sea menor que el stock_actual y la parte que valida que el stock no puede ser negativo.

Lo que no entiendo es porque solo NO funciona con IE.

var idFila = 1;
var addRow;

function addRow(nombreTabla){


var mensaje="";
var entero=0;
var enteroo=0;
var paso=0;

var tbody = document.getElementById(nombreTabla).getElementsBy TagName("TBODY")[0];
var doc_interno = document.getElementById("doc_interno").value;

var row = document.createElement("TR")
idFila++;
row.id = idFila;

var fe_transaccion = document.getElementById("fe_transaccion").value;
var co_bodega = document.getElementById("co_bodega").value;
var co_producto = document.getElementById("co_producto").value;
var nb_producto = document.getElementById("nb_producto").value;
var stock_actual = document.getElementById("stock_actual").value;
var precio = document.getElementById("precio").value;
var co_tipo = document.getElementById("co_tipo").value;
var unidad = document.getElementById("unidad").value;

var linea = document.getElementById("linea").value;


var cantidad = unformatNumber(document.getElementById('cantidad') .value);
var total = cantidad * precio;


---->>>> ESTA SECCION FUNCIONA EN GOOGLE CROME, SAFARI Y MOZILLA, PERO NO EN IE, (Excepto la condicion de co_tipo == a algo, esa si funciona en todos)

if (co_tipo==7) {
var bodega_destino = document.getElementById("co_bodega_destino").value ;


------>>>>>Esto NO funciona en IE.
if (stock_actual < 0)
{
mensaje+=" - NO Puede haber stock Negativo\n";
}

------>>>>>Esto NO funciona en IE.
if (parseInt(document.getElementById("cantidad").valu e) > parseInt(document.getElementById("stock_actual").v alue))
{
mensaje+=" - Cantidad Excede el Stock Actual\n";
}

------>>>>>Esto NO funciona en IE.
if (parseInt(cantidad) < 0)
{
mensaje+=" - Cantidad No puede ser menor que cero\n";
}

------>>>>>Esto NO funciona en IE.
if (isNaN(document.getElementById("cantidad").value)) {
mensaje+=" - Cantidad Debe ser un numero positivo\n";
}


} else {
var bodega_destino = 0;
}


if (co_tipo==2) {

if (stock_actual < 0)
{
mensaje+=" - NO Puede haber stock Negativo\n";
}


if (parseInt(document.getElementById("cantidad").valu e) > parseInt(document.getElementById("stock_actual").v alue))
{
mensaje+=" - Cantidad Excede el Stock Actual\n";
}


if (parseInt(document.getElementById("cantidad").valu e) > 0)
{
mensaje+=" - Cantidad No puede ser menor que cero\n";
}

}

----->>>FIN SECCION QUE NO FUNCIONA EN IE


----->>> TODAS LAS VALIDACIONES SIGUIENTES FUNCIONAN EN TODOS LOS NAVEGADORES

if (stock_actual=="")
{
mensaje+=" - No hay Valor\n";
}





if (unidad=="") mensaje+=" - Falta Unidad\n";

if (precio=="") {
mensaje+=" - Falta el Precio\n";
} else {
if (isNaN(unformatNumber(precio))==true) {
mensaje+=" - El Precio debe ser numerico\n";
} else
{
paso=parseInt(document.getElementById("precio").va lue);

if(paso < 0)
{
mensaje+=" - El Precio debe ser mayor a cero\n";
}
}
}

if (document.getElementById("cantidad").value=="")
{
mensaje+=" - Falta la Cantidad\n" ;
} else {
enteroo=parseInt(document.getElementById("cantidad ").value);

if (isNaN(enteroo)==true) {
mensaje+=" - La cantidad debe ser numerica\n";
} else
{
if (enteroo < 0)
{
mensaje+=" - La cantidad debe ser mayor a cero\n";
}
else
{
document.getElementById("cantidad").value=enteroo;
}

}
}

if (mensaje!="") {
alert("Atencion, se han detectado las siguientes incorrecciones:\n\n"+mensaje);
} else {


//var td00 = document.createElement("TD") ; td00.setAttribute("align","center");
var td0 = document.createElement("TD") ; td0.setAttribute("align","center");
var td1 = document.createElement("TD") ; td1.setAttribute("align","left");
var td2 = document.createElement("TD") ; td2.setAttribute("align","right");
var td3 = document.createElement("TD") ; td3.setAttribute("align","right");
var td4 = document.createElement("TD") ; td4.setAttribute("align","right");
var td5 = document.createElement("TD") ; td5.setAttribute("align","right");

//row.appendChild(td00).innerHTML=linea;
row.appendChild(td0).innerHTML=co_producto;
row.appendChild(td1).innerHTML=nb_producto ;
row.appendChild(td2).innerHTML=precio ;
row.appendChild(td3).innerHTML=formatNumber(cantid ad);
row.appendChild(td4).innerHTML=formatNumber(total) ;
row.appendChild(td5).innerHTML='<input type=button value="-" onclick=javascript:removeRow("tabla_art",'+idFila+ ');>';
tbody.appendChild(row);


///Limpiar
document.getElementById("co_producto").value = " ";
document.getElementById("nb_producto").value = " ";
document.getElementById("stock_actual").value = " ";
document.getElementById("precio").value = " ";
document.getElementById("unidad").value = " ";
document.getElementById("cantidad").value = " ";


paso = unformatNumber(document.getElementById("monto_orde n").value);
paso1 = eval(total);

document.getElementById("monto_orden").value=paso + paso1;
// document.getElementById("monto_orden").value = formatNumber(document.getElementById("monto_orden" ).value);

if (isNaN(formatNumber(document.getElementById("monto _orden").value))==true) {
mensaje+=" - El Total debe Ser Numerico\n";
} else
{
document.getElementById("monto_orden").value = formatNumber(document.getElementById("monto_orden" ).value);
}


document.getElementById("frame_movimiento").src="i nserta_lineasmov.php?doc_interno="+doc_interno
+"&co_producto=" + co_producto +"&precio=" + precio + "&cantidad=" + cantidad + "&total_servicio=" + total
+ "&linea=" + idFila
+"&fe_transaccion="+fe_transaccion + "&co_bodega=" + co_bodega
+ "&stock_actual=" +stock_actual + "&precio=" + precio
+"&co_tipo=" + co_tipo + "&bodega_destino=" + bodega_destino
+"&unidad="+unidad + "&action=agregar";
}
}


function removeRow(nombreTabla, filaAborrar) {


var d = document.getElementById(nombreTabla).firstChild;
var doc_interno = document.getElementById("doc_interno").value;
var tabla = document.getElementById('tabla_art');
var numrowdel = filaAborrar - 1;
var texto = tabla.rows[numrowdel].cells[4].innerHTML;


monto = unformatNumber(document.getElementById("monto_orde n").value);
resta = unformatNumber(texto);

//alert ("monto total orden" + monto);
//alert ("monto a borrar " + resta);

paso = parseFloat(monto) - parseFloat(resta);
paso = formatNumber(paso);

//var tabla = document.getElementById("tabla_art");
//alert(texto);

document.getElementById("monto_orden").value=paso;
d.removeChild(document.getElementById(filaAborrar) );
document.getElementById("frame_movimiento").src="e limina_lineasorden.php?doc_interno="+doc_interno+" &linea=" + idFila + "&action=eliminar";

}


function reordena() {
var tabla = document.getElementById('tabla_art');
var filas = tabla.rows;
for(var i=1; i<filas.length; i++) {
tabla.rows[i].cells[0].innerHTML=i;
//alert("filas " +filas.length);
//alert("linea " +tabla.rows[i].cells[0].innerHTML);
}
}


function formatNumber(num,prefix){
prefix = prefix || '';
num += '';
var splitStr = num.split('.');
var splitLeft = splitStr[0];
var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
var regx = /(\d+)(\d{3})/;
while (regx.test(splitLeft)) {
splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
}
return prefix + splitLeft + splitRight;
}

function unformatNumber(num) {
return num.replace(/([^0-9\.\-])/g,'')*1;
}
  #2 (permalink)  
Antiguo 04/04/2012, 12:33
Avatar de diamari  
Fecha de Ingreso: marzo-2012
Mensajes: 95
Antigüedad: 12 años, 1 mes
Puntos: 30
Respuesta: Script que funciona en Crome, Mozilla, Safari pero no en IE

Has verificado si te da algún error o si es con todo los valores? Como no tengo con que probar es difícil saber cual es problema ya que todo se ve bien asumiendo que los espacios entre paras fueron introducido al pegarlo que.

Etiquetas: funcion, html, input, mozilla, php, safari, chrome
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 13:19.