Ver Mensaje Individual
  #12 (permalink)  
Antiguo 09/05/2009, 15:15
Avatar de rudy69
rudy69
 
Fecha de Ingreso: octubre-2008
Ubicación: espndeportes.com
Mensajes: 195
Antigüedad: 15 años, 6 meses
Puntos: 7
Respuesta: JavaScript solo puede abrir una vez un documento?

funciona a la maravilla!!!!!!! gracias zerokilled, fue ingenioso jaja, deberas no se como no se me habia ocurrido antes, ahora solo retocar cositas y hacer que se vea bonito y quitar esas alertas que como molestan xD, el codigo quedo asi:

Código HTML:
<script language="javascript">
function nuevoAjax()
{ 
	var xmlhttp=false; 
	try 
	{ 
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}

function existeArticulo(art_a_buscar) {
	var button       = document.getElementById('buscar__');
	var msj          = document.getElementById('MsjVentas');
	var mostrador    = document.getElementById('mostrador');
	msj.innerHTML    = '';
	button.disabled  = true;

	if(document.getElementById(art_a_buscar) == undefined) {
	
		var ajax=nuevoAjax();
		ajax.open("POST", "/Libreria/tienda.ajax.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("accion=ExistenciaDeArticulo&IdArticulo="+art_a_buscar);
		
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				var resultado = ajax.responseText;
				if(resultado=='existente') {
					var articuloId  = document.createElement('div');
					articuloId.id   = art_a_buscar;
					mostrador.appendChild(articuloId);
					alert('existe');
					buscarArticulo(art_a_buscar);
				}
				else {
					msj.innerHTML   = 'no existe indio pasmado';
					alert('no existe');
				}
			}
		}
	}
	else {
		alert('ya existe objeto');
		buscarArticulo(art_a_buscar);
	}
	button.disabled = false;
}

function buscarArticulo(articulo) {
	if(document.getElementById('Unidades_'+articulo) == null) {
		var unidades  = 9;
		var descuento = 0;
		alert('entre1');
	}
	else {
		alert('entre2');
		var unidades  = document.getElementById('Unidades_'+articulo).value;
		alert(unidades);
		var descuento = document.getElementById('Descuento_'+articulo).value;
		alert(descuento);
	}
	
	var ajax=nuevoAjax();
	ajax.open("POST", "/Libreria/tienda.ajax.php", true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("accion=CargarArticulo&IdArticulo="+articulo+"&Unidades="+unidades+"&Descuento="+descuento);
	
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			var articuloId       = document.getElementById(articulo);
			articuloId.innerHTML = ajax.responseText;
			alert('entre3');
		}
	}		
}
</script>