Tema: PHP y JS
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/04/2006, 00:21
Avatar de unaiu
unaiu
 
Fecha de Ingreso: abril-2006
Mensajes: 139
Antigüedad: 18 años, 10 meses
Puntos: 0
Hola amigos,

Bien lo siguiente es el codigo de mi aplicacion.Mediante submits ejecuto los botones de adelante,atras,nuevo,guardar... Su funcion, esto es , lo que tienen que hacer lo pongo de forma PHP arriba del todo.

Ahora el problema es que mediante JS me gustaria poder hacer que un boton este enabled o visible, etc...

Codigo:

Cita:
<?php

include("conexionPersonas.php");


if (isset($_POST['accion']) )//si hay algun valor enviado...

{
switch($_POST['accion']) //para saber que boton se ha clickado
{
case "adelante": $_POST['res']=0;
$resultado=$_POST['res'];
$_POST['nuevo']=0;
$nu=$_POST['nuevo'];
if ($_POST['valor']< mysql_num_rows($result)-1)
{
$_POST['valor']++;
$cont=$_POST['valor'];
}
else
$cont=mysql_num_rows($result)-1;
break;
//*****Aqui ba todo el codigo PHP
?>
<html>
<head>
<title>Gestion de Personas</title>
<script>
function mensaje()
{
var resultado;
resultado=<? echo $resultado ?>;
switch (resultado)
{
case 1: alert("El registro se ha modificado.");break;
case 2: alert("El registro se ha guardado ");break;
case 3: alert("Rellena los datos!!");break;
case 4: alert("Escriba bien los datos!!;break;
case 5: alert("El formato del e-mail no es válido.");break;
case 0: break;
}
}


</script>

</head>


<body bgcolor="skate" onLoad=mensaje();>

<CENTER>

<form name="form1" method="post" action="personas.php">
<br>
<center><h2>PERSONAS</h2></center>
<br><br>
Nombre: <input type="text" name="nombre" value="<? echo $matriz[$cont][0]?> "><br><br>

1.Apellido: <input type="text" name="ap1" value="<? echo $matriz[$cont][1]?> "><br><br>

2.Apellido: <input type="text" name="ap2" value="<? echo $matriz[$cont][2]?> "><br><br>

E-Mail: <input type="text" name="email" value="<? echo $matriz[$cont][3]?> "><br><br>




<input type="hidden" name="res" id="res" value=<? echo $resultado?>>
<input type="hidden" name="valor" id="valor" value=<? echo $cont?>>
<input type="hidden" name="accion" id="accion">
<input type="hidden" name="nuevo" id="nuevo" value=<? echo $nu?>>

<input type="submit" name="btnAtras" value="<" onclick=" document.getElementById('accion').value='atras';">

<input type="submit" name="btnAdelante" value=">" onclick=" document.getElementById('accion').value='adelante' ;">

<br><br>
<input type="submit" name="btnNuevo" value="Nuevo" onclick="document.getElementById('accion').value=' nuevo';">

<input type="submit" name="btnCancelar" value="Cancelar" onclick=" document.getElementById('accion').value='cancelar' ;">

<input type="submit" name="btnGuardar" value="Guardar" onclick=" document.getElementById('accion').value='guardar'; ">

</form>

</CENTER>
</body>
</html>

Si alguien sabe alguna manera de hacer referencia a las propiedades de los botones le estaría muy agradecido si me contestara.

Gracias