Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/04/2012, 16:18
wendyl
 
Fecha de Ingreso: marzo-2012
Ubicación: Bogota
Mensajes: 177
Antigüedad: 12 años, 1 mes
Puntos: 2
Respuesta: javascript alertas

Cita:
Iniciado por prod6 Ver Mensaje
ok entonces tendrías que ingeniarltelas para escribir un javascript a partir de php
una manera que se me ocurre es la siguiente:

Código:
<script>
//codigo alert()
</script>

<?php
antes del while yo pondría un:
if (mysql_num_rows = 0){
      echo "<body onload='alert();'>"
}else{
      echo "<body>"
}
?>
pero al no saber como esta conformada tu pagina no sabría decirte la mejor manera
pd: cualquier incoherencia es porque estoy super acostumbrado a sqlsrv y mysql hace añares que no uso!
este es el index.php

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';
		if ($logueados==0) { 
			var alerta= "no hay agentes logueados";
			confirm(alerta );
   //acciones a realizar en caso positivo 
   //... 
		} else { 
   //acciones a realizar en caso negativo 
   //... 
		} 
	}
	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()">Actualizar Info<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="228" height="290" 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> 


Código PHP:
<? 
include("conexion.php");
$linkconexion();
$sql=mysql_query("select logueados,disponibles,llamada_externa,campaña,auxiliar,acw,otros from estadosskill15 ")
or die (
"problemas en el select".mysql_error());

while(
$row=mysql_fetch_array($sql))
    {
        
$logueados=$row['logueados'];
        
$disponibles=$row['disponibles'];
        
$llamada_externa=$row['llamada_externa'];
        
$campaña=$row['campaña'];
        
$auxiliar=$row['auxiliar'];
        
$acw=$row['acw'];
        
$otros=$row['otros'];
    }
    
//Elimina toda la data de la tabla 
  
$mysql mysql_query("DELETE FROM estadosskill15") or die ("Problemas al eliminar informacion. ".mysql_error()); 

    
    

?>
y este es donde me captura logueados

donde podria el alert

gracias por tu ayuda :)