Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/10/2009, 14:13
7xtr3am
 
Fecha de Ingreso: marzo-2009
Mensajes: 73
Antigüedad: 15 años, 1 mes
Puntos: 1
problemas con formularios

hola espero que alguien me pueda ayudar a entender esto, hice el siguiente codigo pero cuando pongo el cursor en textfield3 y presiono Enter se ejecuta el submit (como es de esperarse) pero tambien se ejcuta el onclick de imageField.

alguien sabe por que y como evitarlo?

Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>

<script type="text/javascript">
	function a()
	{
		document.getElementById("textfield5").value = "qwerty";
	}
</script>

<form name="" action="" onsubmit="alert('ok submit'); return false;" enctype="application/x-www-form-urlencoded">
<table border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>a</td>
    <td><input type="text" name="textfield1" /></td>
    <td><input type="image" name="imageField" src="img.png" width="40" height="40" onclick="a()" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>b</td>
    <td><input type="text" name="textfield2" /></td>
    <td><input type="submit" onclick="alert('click submit');" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>c</td>
    <td><input type="text" name="textfield3" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>d</td>
    <td><input type="text" name="textfield4" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>e</td>
    <td><input type="text" name="textfield5" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>

</body>
</html>