Revolution X

Coding Community => Coding Snippets => Topic started by: Agent Moose on September 07, 2009, 06:43:29 pm



Title: New Search Bar
Post by: Agent Moose on September 07, 2009, 06:43:29 pm
Footers:
Code:
<script type="text/javascript">
var a = document.getElementsByTagName("form");
for(x=0;x<a.length;x++){
//Created by Agent Moose (revolutionx.smfforfree3.com)
if(a[x].action.match(/action=search2/i) && a[x].parentNode.valign == "top" && a[x].nowrap == "nowrap" && a[x].parentNode.parentNode.parentNode.parentNode.id == "upshrinkHeader2" && location.href.match(/board,(\d+)./i)){
a[x].innerHTML = "<form id='searchform' name='searchform' accept-charset='ISO-8859-1' method='post' action='" + smf_scripturl + "action=search2'><input type='text' style='width: 190px;' name='search'/><input id='brd" + RegExp.$1 + "' type='hidden' checked='checked' value='" + RegExp.$1 + "' name='brd[" + RegExp.$1 + "]'/><input type='submit' value='Search' name='submit'/></form>"
};};
</script>

Original Request: http://revolutionx.smfforfree3.com/index.php/topic,1073.0.html

This code is very simple.  It changes the search bar you have up top, to make it only search the board that you are in.  If you are on the index page, or any other page that doesn't deal with a board, it will search the whole forum :)

Enjoy :)


Title: Re: New Search Bar
Post by: xboi209 on September 07, 2009, 07:04:37 pm
hmm, i didn't expect this to be in the footers though but its still good :)


Title: Re: New Search Bar
Post by: Agent Moose on September 07, 2009, 08:57:39 pm
If you put it in the headers, it would be to high to get anything :P


Title: Re: New Search Bar
Post by: xboi209 on September 07, 2009, 09:03:39 pm
yea but i was thinking of having one where you can put it anywhere you want.


Title: Re: New Search Bar
Post by: DzinestaR on September 07, 2009, 10:08:04 pm
That's a great code.

-DzinestaR


Title: Re: New Search Bar
Post by: Agent Moose on September 08, 2009, 09:14:31 am
yea but i was thinking of having one where you can put it anywhere you want.

I could make it so you can put it in the headers or footers :)  it will still have the same concept of searching what ever board you are viwing.


Title: Re: New Search Bar
Post by: xboi209 on September 08, 2009, 04:40:36 pm
no thanks  ::)