Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Form Submission


tonynoriega - 5:18 pm on Jan 12, 2012 (gmt 0)


New to JS, so please bare with me.
I have a fairly simple search form field on my site:

<script type="text/javascript">
function RunSearch() {
window.location.href = "http://searcher.example.com:8765/query.html?ql=&col=web1&qt=" + document.getElementById("search").value;
}
</script>
<div class="formSrchr">
<input type="text" size="20" name="qt" id="search" value="Search" onfocus="if(this.value == 'Search') {this.value=''}" onblur="if(this.value == ''){this.value ='Search'}" />
<input type="hidden" name="qlOld" id="qlOld" value="" />
<input type="hidden" name="colOld" id="colOld" value="web1" />
<input type="image" name="imageField" alt="search" src="/_images/search-mag.gif" onclick="RunSearch();" />
</div>


However, in Chrome and Firefox, when you press enter, it does not submit the form. Works in IE.

I understand I need to add an
<input type="submit" style="visibility:hidden;" >
field.

But how can I still utilize the input image button, and submit by pressing enter?

Don't I have to pick one or the other?

thx


Thread source:: http://www.webmasterworld.com/javascript/4406201.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com