Foros del Web » Programando para Internet » PHP »

alert js y php

Estas en el tema de alert js y php en el foro de PHP en Foros del Web. necesito de su ayuda lo que necesito hacer es una serie de alertas me explico este es mi index y se actualiza cada segundo en ...
  #1 (permalink)  
Antiguo 03/05/2012, 09:53
 
Fecha de Ingreso: marzo-2012
Ubicación: Bogota
Mensajes: 177
Antigüedad: 12 años
Puntos: 2
Sonrisa alert js y php

necesito de su ayuda lo que necesito hacer es una serie de alertas

me explico este es mi index y se actualiza cada segundo en la parte superior tengo 7 botones
1.datos
2. voz... y asi susecivamente

en cada boton tengo una imagen .JPG y cuando doy click a cada boton muestra una serie de informacion dependiendo de el q se quiera ver ej: si doy click en datos me muestra agentes logueados, diponibles, llamadas en cola, tiempo de llamada etc

cada variable la consulto en la bd y necestio que cuando $logueados == 0 me genere un alert ('no hay agentes logueados')y que la imagen del boton me cambie a una .GIF para yo poder saber en q boton se encuentra la alarma


Código HTML:
<html>
<head>
<meta http-equiv="refresh" content="60">
	<title>Actualizador BD</title>
	<script>
		/*
* Parametros mandatorios
*/
    var seconds = 1; // el tiempo en que se refresca
	var divid = "tabla"; // el div que quieres actualizar!
	var nocacheurl = 'tabla.php';
	
	//var url = "tiempo.php"; // el archivo que ira en el div

	function refreshdiv(){

		// The XMLHttpRequest object

		var xmlHttp;
		try{
			xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
		}
		catch (e){
			try{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
			}
			catch (e){
				try{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e){
					alert("Tu explorador no soporta AJAX.");
					return false;
				}
			}
		}

		// Timestamp for preventing IE caching the GET request
		var timestamp = parseInt(new Date().getTime().toString().substring(0, 10));
		

		// The code...

		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState== 4 && xmlHttp.readyState != null){
				document.getElementById(divid).innerHTML=xmlHttp.responseText;
				setTimeout('refreshdiv()',seconds*1000);
			}
		}
		xmlHttp.open("GET",nocacheurl,true);
		xmlHttp.send(null);
	}

	// Empieza la función de refrescar

	window.onload = function(){
		refreshdiv(); // corremos inmediatamente la funcion
	}
	
	function Datos(){
		//var alerta= "";
		//confirm(alerta );
		nocacheurl='tabladatos.php';
	}
	
	function Voz(){
		//var alerta= "";
		//alert(alerta);
		nocacheurl = 'tablavoz.php';
	}
	function Mintic(){
		//var alerta= "";
		//alert(alerta);
		nocacheurl = 'tablamintic.php';
	}
	function InfoTicket(){
		//var alerta= "";
		//alert(alerta);
		nocacheurl = 'tablainfo_ticket.php';
	}
	function SoporteOS(){
		//var alerta= "";
		//alert(alerta);
		nocacheurl = 'tablasoporte.php';
		 
	}
	function MCF(){
		//var alerta= "";
		//alert(alerta);
		nocacheurl = 'tablamcf.php';
	}
	function ActualizarInfo(){
		//var alerta= "";
		//alert(alerta);
		nocacheurl = 'tablaactualizar_info.php';
	}
</script>	
<style type="text/css">

.estilo1 {
font-family: Trebuchet MS;
font-size: 20px;
color: #000000;
font-weight: bold;
}
</style>
<script>

</script>

</head>
<body >
<!--alerta.gif -->	
	<?php
		$botones='
		<div id="Principal" align="left">
		<button id="Datos" onclick="Datos()">Datos<input type="image" src="images/alarma_apagada1.jpg"/ width="40" height="35"></button>
		<button id="Voz" onclick="Voz()">Voz <input type="image" src="images/alarma_apagada1.jpg" width="40" height="35"/></button>
		<button id="Mintic" onclick="Mintic()">Mintic <input type="image" src="images/alarma_apagada1.jpg" width="40" height="35"/></button>
		<button id="InfoTicket" onclick="InfoTicket()">Info Ticket <input type="image" src="images/alarma_apagada1.jpg" width="40" height="35"/></button>
		<button id="SoporteOS" onclick="SoporteOS()">Soporte o/s <input type="image" src="images/alarma_apagada1.jpg" width="40" height="35"/></button>
		<button id="MCF(" onclick="MCF()">MCF <input type="image" src="images/alarma_apagada1.jpg" width="40" height="35"/></button>
		<button id="ActualizarInfo(" onclick="ActualizarInfo()">AIC <input type="image" src="images/alarma_apagada1.jpg" width="40" height="35"/></button>
		Alarma por: <input type="text" name="" value="" /> 
		<img src="images/informe.jpg" width="280" height="180" align="center">
		</div>';
		echo $botones;
		
		echo '<div id="tabla">' ;
		echo "</div>";
		
		/*alertas 
		Hay una llamada en cola superior a un min
		Hay mas de 2 llamadas en cola
		No hay agentes disponibles
		no hay ningu agente logueado
		
		*/
		
	?>
	

</body>
</html> 
no se como hacerlo ya q los alert son js y la consulta es php
porfavor necesito de su ayuda

gracias
  #2 (permalink)  
Antiguo 03/05/2012, 10:52
Avatar de Karmac  
Fecha de Ingreso: agosto-2011
Ubicación: Bilbao
Mensajes: 196
Antigüedad: 12 años, 8 meses
Puntos: 34
Respuesta: alert js y php

Haz por ejemplo en PHP:
Código PHP:
Ver original
  1. <?php echo 'error'; ?>

Y luego con JS (pongamos que 'result' contenga la petición):
Código Javascript:
Ver original
  1. if (result == 'error' ) alert('No hay agentes logeados!');

¿Te refieres a algo así?

Etiquetas: html, js, tabla, alerta, variables
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 10:40.