4 messages in com.googlegroups.google-gadgets-apiRe: newbie javascript question
FromSent OnAttachments
Héctor16 Dec 2007 10:54 
Peter Svensson16 Dec 2007 11:23 
Héctor16 Dec 2007 13:32 
Justin McConnell18 Dec 2007 16:29 
Subject:Re: newbie javascript question
From:Justin McConnell (bool@gmail.com)
Date:12/18/2007 04:29:21 PM
List:com.googlegroups.google-gadgets-api

On Dec 16, 10:55 am, "Héctor" <hecp@gmail.com> wrote:

Hi,

I'm writing my first Google Gadget and I would like that pressing the enter key does the same as clicking on the button:

Use onsubmit of the form instead of onclick on the button. That way, any way the user submits the form, your function will be called.

... description="e.g. Seek Madrid in Wikipedia: w/Madrid, Spanish Wikipedia: w/es/Madrid, Google Maps: maps/Madrid, Google Maps in Spanish: maps/es/Madrid and so on (Technorati, Wordreference, ...)" ... <![CDATA[ <form> <table> <tr> <td><input type='text' id='search'/></td> <td><input type='button' onclick="goto_seekr(document.getElementById('search'))" value='Seekr' /></td> </tr> </table> </form> <script language="javascript" type="text/javascript"> function goto_seekr(elem){ window.open("http://seekr.es/" + elem.value);}

</script> ]]> ...

<![CDATA[ <form onsubmit="goto_seekr(this.search); return false;"> <table> <tr> <td><input type='text' id='search'/></td> <td><input type='submit' value='Seekr' /></td> </tr> </table> </form> <script language="javascript" type="text/javascript"> function goto_seekr(elem){ window.open("http://seekr.es/" + elem.value); }

</script> ]]>

How could I do that?

Thanks!

Héctor

PS. Completed code:http://hosting.gmodules.com/ig/gadgets/file/10841488415