1

I am new to website coding and am using the Webplus site search tool. However I only want it to search certain pages on my site, and have discovered that by including a word on the pages I want searching and then including that (hidden) in the search input, it will only browse these pages.

I have tried the following code:

<DIV ALIGN=CENTER>
<form id="site_search_1" action="" onSubmit="return false;" style="position: absolute; top:117px; left:584px; width:250px; height:44px;margin: 0; padding: 0;">
  <input id="site_search_1_input" value="                                              secret" name="site_search_1_input" onkeypress="
    if (event.keyCode==13)
      window.location.href='results.html?site_search_results_1='+document.getElementById('site_search_1_input').value+'&amp;depth=0;"
  style="width: 170px; border: none; /* EditStyle */" type="text">
<div style="display: inline;">
  <input type="image" src="wpimages/Search Icon.png" style="position: absolute; top:-5px; left:220px;" button onclick="
    window.location.href='results.html?site_search_results_1='+document.getElementById('site_search_1_input').value+'&amp;depth=0';"
  value="Search" name="submit" onfocus="this.blur()" onmouseover="this.src='wpimages/Search Icon (H).png'" onmouseout="this.src='wpimages/Search Icon.png'" onmousedown="this.src='wpimages/Search Icon (H).png'"/>
</div>
</form>
<script type="text/javascript" language="JavaScript">
document.forms['site_search_1'].elements['site_search_1_input'].focus();
</script>
</DIV>

but this is a bit messy and thought their may be a way to search using 2 inputs, one with the secret word as the value, but being hidden. Any help would be much appreciated and any alternative ways of searching only specified pages using some basic code is welcome.

Ferdinand.kraft
  • 12,579
  • 10
  • 47
  • 69
Chris
  • 21
  • 2
  • Tried to edit your code but it was so much inline JS that it didn't go. I have never seen that kind of inline JS on a `input type="submit" `button... – Sergio Sep 01 '13 at 21:32
  • Chris, were did you find that code? – Sergio Sep 01 '13 at 21:35
  • It is the code from the serif webplus site search with the addition of the value="secret" and an image for the search button – Chris Sep 01 '13 at 21:38
  • Chris, that code is not so good... sorry to disappoint you on the code you found but it's the truth. Can you describe better what you expect the search function to do, maybe there is another way than working with that code. – Sergio Sep 01 '13 at 21:44
  • I want a site search that shows results for certain pages (ie. I don't want it to find the home page etc). I thought this could be achieved by searching 2 input fields one that the user can fill in and the other being a hidden field with a word in that is on all the pages that I want to be searched. – Chris Sep 01 '13 at 21:48
  • My suggestion: Abandon this code and read this: http://stackoverflow.com/questions/3016287/how-to-add-site-search-function-to-website-using-xhtml-html - and this: http://stackoverflow.com/questions/34314/how-do-i-implement-search-functionality-in-a-website – Sergio Sep 01 '13 at 21:52

0 Answers0