Search Form

liunx

Guest
Hi,<br />
I've got a bit of Javascript for searching my pages and I've called the function search(). I have a form for submitting keywords to the search and so in the button input type I have something saying onClick="search()". This works fine but I want it so that people can press return and it will search, whereas at the moment they need to click he button. I know to do this I know that in the <form> bit I need a method="" and an action="" line. However the action takes you to a new page, and I was wondering if there is a way to link it to the function at the top of the page. Or a simpler way that I've overlooked. I warn you that I'm a bit of a newbie at Javascript, but learning all the time.<br />
Cheers<br />
IxxI<!--content-->IIRC, you can have your submit button be a standard submit button without an onClick event, and set the action attribute of the form tag to run your JavaScript code. Something like...<br />
<br />
<form method="get" action="javascript:Search()"><br />
<br />
I have not tested this, and do not know if it is technically "valid" or not, but it's a place to start anyway.<br />
<br />
(If someone better at JS sees something wrong with this, please club me over the head with an iron skillet for posting at 3:00am in a half-sleep daze. Thank you.)<!--content-->Sorry, I've found a way. I'm using an onSubmit="search()" command in my <form....>. Thanks for the reply though.<br />
IxxI<!--content-->
 
Back
Top