1

I have a search text field on my site that seems to not be operating properly in Chrome nor FireFox... but working in IE (all versions)...

Is there something I am doing wrong? I am unable to find why the value is not being passed to the "searcher" application.

<div class="searchbox" id="searchbox"> 
    <script type="text/ecmascript"> 
        function RunSearch() { 
            window.location = "http://searcher.myexampledomain.com:8765/query.html?ql=&amp;col=web1&amp;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> 
</div> <!-- /searchbox -->
tony noriega
  • 7,523
  • 17
  • 53
  • 72

2 Answers2

4

You shouldn´t HTML encode the & in you URL.

This would be enough;

window.location.href = "http://searcher.myexampledomain.com:8765/query.html?ql=&col=web1&qt=" + document.getElementById("search").value;

Stefan
  • 5,644
  • 4
  • 24
  • 31
  • 1
    OP should also consider using `window.location.href` instead of `window.location` as pointed out in the following question: http://stackoverflow.com/questions/2345807/window-location-does-not-work-on-chrome-browser – Alex Jan 12 '12 at 16:16
  • It was the ampersand sign... thank you.. Changed those two instanced to not encoded symbols, and it works now. Can I follow up to this question...?? why when I just hit the "enter" button, it does not submit again, for Chrome or FF, but works in IE??? – tony noriega Jan 12 '12 at 16:37
  • Your form doesn´t contain any `submit` button. ``. – Stefan Jan 12 '12 at 16:40
  • You could move your function call from the `input` `onclick` attribute to the `form`s `onsubmit` and add a hidden submit button within the `form`. See http://stackoverflow.com/questions/29943/how-to-submit-a-form-when-the-return-key-is-pressed for hidden submit button. – Stefan Jan 12 '12 at 16:44
  • Can i not also use the image to submit as well ? – tony noriega Jan 12 '12 at 16:57
2
<script type="text/ecmascript"> 

Is maybe the problem, and cause the difference of reaction between browsers. Try to change it in :

<script type="text/javascript"> 
jbrtrnd
  • 3,815
  • 5
  • 23
  • 41