Dinámica de las acciones para una forma

  • Pop-Eye
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Jul 07, 2010
  • Mensajes: 5
  • Status: Offline

Nota Julio 8th, 2010, 7:38 am

Al intentar cargar las páginas diferente cuando se hace clic en las imágenes diferentes. Tengo el siguiente, que no funciona:
Código: [ Select ]
<form>
<input type='image' src='./img/pic1.jpg' onclick="this.form.action.value='xyz.php';this.form.submit();">
<input type='image' src='./img/pic2.jpg' onclick="this.form.action.value='abc.php';this.form.submit();">
</form>
  1. <form>
  2. <input type='image' src='./img/pic1.jpg' onclick="this.form.action.value='xyz.php';this.form.submit();">
  3. <input type='image' src='./img/pic2.jpg' onclick="this.form.action.value='abc.php';this.form.submit();">
  4. </form>


Cualquier ayuda será apreciada.
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Julio 8th, 2010, 7:38 am

  • PolishHurricane
  • Mastermind
  • Mastermind
  • Avatar de Usuario
  • Registrado: Feb 17, 2005
  • Mensajes: 1585
  • Status: Offline

Nota Julio 11th, 2010, 6:58 am

Basta con retirar la extensión ". Valor".

Código: [ Select ]
<form method="post">
<input type='image' src='./img/pic1.jpg' onclick="this.form.action='xyz.php';this.form.submit();">
<input type='image' src='./img/pic2.jpg' onclick="this.form.action='abc.php';this.form.submit();">
</form>
  1. <form method="post">
  2. <input type='image' src='./img/pic1.jpg' onclick="this.form.action='xyz.php';this.form.submit();">
  3. <input type='image' src='./img/pic2.jpg' onclick="this.form.action='abc.php';this.form.submit();">
  4. </form>


He añadido method = "post" por lo que no se presentó en la X y VARs y al enviar el formulario por GET en lugar de POST.
There's no place like 127.0.0.1, badass part is now it's ::1
  • Pop-Eye
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Jul 07, 2010
  • Mensajes: 5
  • Status: Offline

Nota Julio 12th, 2010, 11:19 am

Gracias por la respuesta. Funcionó bien. :P
  • PolishHurricane
  • Mastermind
  • Mastermind
  • Avatar de Usuario
  • Registrado: Feb 17, 2005
  • Mensajes: 1585
  • Status: Offline

Nota Julio 12th, 2010, 11:46 am

Algo debe andar mal con su código de entonces. El siguiente es un ejemplo de archivo HTML 5, la carga por primera vez "xyz.php", la segunda carga "abc.php". Yo alt = "" etiquetas, ya que no tienen sus fotos.

Código: [ Select ]
<!DOCTYPE html>
<html lang="en-us" dir="ltr">
<head>
</head>
<body>

 <form method="post">
 <input type='image' alt="XYZ" src='./img/pic1.jpg' onclick="this.form.action='xyz.php';this.form.submit();">
 <input type='image' alt="ABC" src='./img/pic2.jpg' onclick="this.form.action='abc.php';this.form.submit();">
 </form>

</body>
</html>
  1. <!DOCTYPE html>
  2. <html lang="en-us" dir="ltr">
  3. <head>
  4. </head>
  5. <body>
  6.  <form method="post">
  7.  <input type='image' alt="XYZ" src='./img/pic1.jpg' onclick="this.form.action='xyz.php';this.form.submit();">
  8.  <input type='image' alt="ABC" src='./img/pic2.jpg' onclick="this.form.action='abc.php';this.form.submit();">
  9.  </form>
  10. </body>
  11. </html>
There's no place like 127.0.0.1, badass part is now it's ::1

Publicar Información

  • Total de mensajes en este tema: 4 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 156 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC