Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/04/2009, 16:35
midas84
 
Fecha de Ingreso: agosto-2008
Mensajes: 14
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Problamas con boton creado mediante dom y problas I.E. - M.F.

Código:
	addEvent(window,'load',inicializarEventos,false);
var ps;
var codigo=document.getElementById('validacion');
var df=1;
var conexion1;
var conexion2;
var conexion3;
	function inicializarEventos(){
	var boton=document.getElementById('accion');
	var ed=document.getElementById('ps')	
		addEvent(boton,'click',clave,false);
	}
	function ac(){
		clave();
		return false;
	}
	function clave(e){
		ps=	document.getElementById('ps');
		us=	document.getElementById('us');
	var nuevotexto=document.getElementById('res');
		if ((ps.value!="")&&(us.value!=""))
		{
  			nuevotexto.innerHTML="";
    		conexion1=crearXMLHttpRequest();
    		conexion1.onreadystatechange = VerPs;
    		conexion1.open('GET','bitacora/ps.php?ps='+ps.value+'&us='+us.value, true);
    		conexion1.send(null);
		}
  		else
  		{
    		nuevotexto.innerHTML="<p>Introdusca su contraseña</p>";
  		}	
	}
	function menu(){
	xml3 = conexion3.responseXML;
    var cant=xml3.getElementsByTagName('cant');
    cantidad= cant[0].firstChild.nodeValue;
	//cantidad=100;
	var men=document.getElementById('men');
		tabla = document.createElement('table');
		//tabla.setAttribute('id','m');
		men.appendChild(tabla);
		elmTBODY= document.createElement('tbody');
		tabla.appendChild(elmTBODY);
		elmTR =document.createElement('tr');
    	elmTBODY.appendChild(elmTR);	 
    	elmTD = document.createElement('th');
		elmTR.appendChild(elmTD);
		elmText = document.createTextNode("Ordenar Por:");
		elmTD.appendChild(elmText);
		elmTD = document.createElement('th');
		elmTR.appendChild(elmTD);
		elmText = document.createTextNode("Orden:");
		elmTD.appendChild(elmText);
		elmTD = document.createElement('th');
		elmTR.appendChild(elmTD);
		elmText = document.createTextNode("Página:");
		elmTD.appendChild(elmText);

		elmTR =document.createElement('tr');
    	elmTBODY.appendChild(elmTR);		
		elmTD = document.createElement('td');
		elmTR.appendChild(elmTD);
		selec= document.createElement('select');
		//selec.setAttribute('id','ordenar');
    	opt= document.createElement('option');
    	elmText = document.createTextNode("IdUsuario");
    	opt.appendChild(elmText);
    	selec.appendChild(opt);
    	opt= document.createElement('option');
    	elmText = document.createTextNode("FechaHoraRegistro");
    	opt.appendChild(elmText);
    	selec.appendChild(opt);
    	opt= document.createElement('option');
    	elmText = document.createTextNode("Accion");
    	opt.appendChild(elmText);
    	selec.appendChild(opt);
    	elmTD.appendChild(selec); 
    	
    	
    	elmTD = document.createElement('td');
		elmTR.appendChild(elmTD);
		selec= document.createElement('select');
		//selec.setAttribute('id','orden');
    	opt= document.createElement('option');
    	elmText = document.createTextNode("Ascendente (^)");
    	opt.appendChild(elmText);
    	selec.appendChild(opt);
    	opt= document.createElement('option');
    	elmText = document.createTextNode("Descendente(v)");
    	opt.appendChild(elmText);
    	selec.appendChild(opt);
    	elmTD.appendChild(selec);
		
		                                                      
			 
    	elmTD = document.createElement('td');
		elmTR.appendChild(elmTD);
		selec= document.createElement('select');
		//selec.setAttribute('id','pag');
		elmTD.appendChild(selec);
    		 
		for (var i=0; i<(cantidad/20); i++){
			opt= document.createElement('option');
    		selec.appendChild(opt);
			elmText = document.createTextNode(i);
    		opt.appendChild(elmText);
    		
    	}
		//elmTD = document.createElement('td');
		//elmTR.appendChild(elmTD);
		//bot= document.createElement('button');
		//bot.action=false;
		//codigo.appendChild(bot);
		//addEvent(bot,'click',hola,false);
		//elmTD.appendChild(bot);
		//setAttribute('value','hola');
		//addEvent(bot,'click',hola,false);
		
	}
		
	function VerPs(){
	var xml = conexion1.responseXML;
	var pals=xml.getElementsByTagName('resp');
    	if (pals[0].firstChild.nodeValue=='si'){
    		if (df==1){
				df=2;
				//menu();
				conexion3=crearXMLHttpRequest();
    			conexion3.onreadystatechange = menu;//generar menu
    			conexion3.open('GET','bitacora/pag.php', true);  //llamada paginación
    			conexion3.send(null);
				                             
			}
			mirar();
    	var nuevotexto=document.getElementById('res');
			nuevotexto.innerHTML="Contraseña correcta|"+pals[0].firstChild.nodeValue;
		
		
		}
    	else{
		var nuevotexto=document.getElementById('res');
			nuevotexto.innerHTML="Contraseña incorrecta|"+pals[0].firstChild.nodeValue;
			
		} 
	}
	function mirar(){
		conexion2=crearXMLHttpRequest();
    		conexion2.onreadystatechange = mostrar;
    		conexion2.open('GET','bitacora/lista.php?ord=desc&nom=idusuario&pag=3&func=1', true);
    		conexion2.send(null);
	}
	function mostrar(){
	var xml1 = conexion2.responseXML;
    var no=xml1.getElementsByTagName('no');
    var fecha=xml1.getElementsByTagName('fecha');
    var id=xml1.getElementsByTagName('id');
    var accion=xml1.getElementsByTagName('accion');
	codigo=document.getElementById('validacion');
		while (codigo.childNodes.length>0) {
			codigo.removeChild(codigo.childNodes[0]);
		}	
 		tabla = document.createElement('table');
		codigo.appendChild(tabla);
		elmTBODY= document.createElement('tbody');
		tabla.appendChild(elmTBODY);
		elmTR =document.createElement('tr');
    	elmTBODY.appendChild(elmTR);
    	
    		elmTD = document.createElement('th');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(no[0].firstChild.nodeValue);
			elmTD.appendChild(elmText);	
				elmTD = document.createElement('td');
				elmTR.appendChild(elmTD);
			elmTD = document.createElement('th');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(fecha[0].firstChild.nodeValue);
			elmTD.appendChild(elmText);
				elmTD = document.createElement('td');
				elmTR.appendChild(elmTD);
			elmTD = document.createElement('th');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(id[0].firstChild.nodeValue);
			elmTD.appendChild(elmText);
			 	elmTD = document.createElement('td');
				elmTR.appendChild(elmTD);
			elmTD = document.createElement('th');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(accion[0].firstChild.nodeValue);
			elmTD.appendChild(elmText);
		
		for (var i=1; i<no.length; i++){//genera tabla
			elmTR =document.createElement('tr');
    		elmTBODY.appendChild(elmTR);
    	
    		elmTD = document.createElement('td');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(no[i].firstChild.nodeValue);
			elmTD.appendChild(elmText);
				elmTD = document.createElement('td');
				elmTR.appendChild(elmTD);	
			elmTD = document.createElement('td');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(fecha[i].firstChild.nodeValue);
			elmTD.appendChild(elmText);
				elmTD = document.createElement('td');
				elmTR.appendChild(elmTD);
			elmTD = document.createElement('td');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(id[i].firstChild.nodeValue);
			elmTD.appendChild(elmText);
				elmTD = document.createElement('td');
				elmTR.appendChild(elmTD);
			elmTD = document.createElement('td');
			elmTR.appendChild(elmTD);
			elmText = document.createTextNode(accion[i].firstChild.nodeValue);
			elmTD.appendChild(elmText);
		
		} 
	}

//***************************************
//Funciones comunes a todos los problemas
//***************************************
function addEvent(elemento,nomevento,funcion,captura)
{
  if (elemento.attachEvent)
  {
    elemento.attachEvent('on'+nomevento,funcion);
    return true;
  }
  else  
    if (elemento.addEventListener)
    {
      elemento.addEventListener(nomevento,funcion,captura);
      return true;
    }
    else
      return false;
}

function crearXMLHttpRequest() 
{
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
}