Jump to content

Enter Key


suzie

Recommended Posts

Hi,We are working on a new website, and I did a search Field...I want that when the visitor enter the keyword to search, and PRESS Enter to start search and not when he press on an image Icon.How that can be done, how can I make an action when the Enter Key is pressedthank you

Link to comment
Share on other sites

The default action when someone presses the enter key while the focus is on an input element, in a HTML form, is for the form to be submitted.

Link to comment
Share on other sites

yeah I have a form like:<form name="searchform" method="POST" action=\"search.php?type=$type&search=articles&day=$day" onSubmit=""><input style="TEXT-ALIGN: right; FONT-FAMILY: arial; COLOR: #666666; FONT-SIZE: 9pt; background-image:url(text-field.gif); border:#0000FF; border:" dir="rtl" id="textbox_id" value="search here" onfocus="if (this.value == 'search here') { this.value=''; }" onblur="if(this.value==''){this.value='search here';}"size="16" name="input" /><input id="search_img" type="image" src="images/search-icon.gif" width="20" height="16" border="0" style="vertical-align:middle" onMouseOver="MM_swapImage('search_img','','images/search-icon2.gif',1)" onMouseOut="MM_swapImgRestore()">hfhh</form>So in this case, the search starts when press on image,what shall i do if I want to change it to start when ENTER Key is pressed??thank you for your help

Link to comment
Share on other sites

You really should get that CSS out of the HTML tag and put it in a style sheet. :) It'll make your code a lot easier to read. You should also get rid of the deprecated style attributes in your tags (size, dir, border, width, height, etc) and put that stuff in CSS instead.Anyhow, you're missing a type attribute for your first input box (name='input'). As Synook said, by default a form will submit when a user presses enter while focus is on an input. I think the missing type attribute is messing it up.

Link to comment
Share on other sites

Also, what's with the random backslash and dollar signs?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...