Help With Search Box/form

This is a discussion on "Help With Search Box/form" within the Web Page Design section. This forum, and the thread "Help With Search Box/form are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 3rd, 2007, 15:40
New Member
Join Date: Oct 2007
Location: uk
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Help With Search Box/form

Hi i am trying to create a search box on a site which will take you to the following page when you click the submit button:

www.mysite.co.uk/shop/compareprices/searchterm.htm
"searchterm" being the variable submitted in the search box

At present i have the following search box/form:
<form style="margin-bottom:0;" action="http://www.mysite.co.uk/shop/index.php" method="get">
<input name="ps" type="text" value="Enter Keywords" onfocus="if(this.value=='Enter Keywords'){this.value=''; this.style.color='#000000';}" size=18 />&nbsp;<input type="hidden" name="sv" value="1" />
<input type="submit" class="srchsubmit" value="Go" />
</form>

This takes you to:
http://www.mysite.co.uk/shop/index.php?ps=searchterm&sv=1

I have already got the mod rewrite working all i need is a searchbox/form which will take you to www.mysite.co.uk/shop/compareprices/searchterm.htm when submitted.

is it possible to do this?

Any help appreciated.

William
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 3rd, 2007, 15:44
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Help With Search Box/form

why not just use the following in your search script (index.php?ps=searchterm&sv=1)
PHP: Select all

header ("Location: /shop/compareprices/searchterm.htm"); 

Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 3rd, 2007, 17:48
New Member
Join Date: Oct 2007
Location: uk
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help With Search Box/form

Not really what i am after alexgeek.

What i really need is the search form code as i what it use the same search/form on deferent sites.
Maybe i wasnt to clear about what i need.
I want the form action to take you to for example:
www.mysite.co.uk/shop/compareprices/widget.htm
(with "widget" being the term submited in the search form)
So what i need is the code for the form which will do this.

I probably confused things mentioning the mod rewrite, the search form is what i need to get working.


William
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 3rd, 2007, 22:04
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Help With Search Box/form

Modrewrite would work for this,
I am probably wrong,
but you might have to do something like the following:

HTML: Select all
 <form action="/shop/compareprices.php" method="GET">
input boxes
</form>
Which would take you to:
www.mysite.co.uk/shop/compareprices.php?search=searchterm

Then you can use modrewrite to make this:

www.mysite.co.uk/shop/compareprices/searchtem
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 4th, 2007, 11:29
Reputable Member
Join Date: Sep 2007
Location: UK
Age: 42
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help With Search Box/form

Quote:
Originally Posted by alexgeek View Post
I am probably wrong,
Then why talk?

im sure someone will come to help you out. (karinne is homing in on our distress signal now)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 4th, 2007, 12:01
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help With Search Box/form

You could solve this with javascript. A script like this could do the trick:
HTML: Select all
<script type="text/javascript">
function postForm() {
    window.location = "www.mysite.co.uk/shop/compareprices/"+(getElementById('ps').value)+".htm";
    return false;
}
</script>

<form style="margin-bottom:0;" action="http://www.mysite.co.uk/shop/index.php" method="get" onsubmit="return postForm();">
<input name="ps" id="ps" type="text" value="Enter Keywords" onfocus="if(this.value=='Enter Keywords'){this.value=''; this.style.color='#000000';}" size=18 />&nbsp;<input type="hidden" name="sv" value="1" />
<input type="submit" class="srchsubmit" value="Go" />
</form>
I haven't tested this, but see if that works. Of course if the client has javascript disabled, this won't work.

I think a PHP / mySQL solution would be better for something like this, but good luck however you do it.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 4th, 2007, 15:04
New Member
Join Date: Oct 2007
Location: uk
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help With Search Box/form

Thanks c010depunkk, I just saw your post.

I came up with something similar myself
Code: Select all
<form style="margin-bottom:0;" name="searchprod" action="java script:jumpit(document.searchprod.keyword.value)">
<input type="text" size="18" name="keyword" value="Enter Keywords" onfocus="if(this.value=='Enter Keywords'){this.value=''; this.style.color='#000000';}" />
<input type="submit" class="srchsubmit" value="Go" onClick="jumpit()">
</form>
 
<script language="JavaScript">
function jumpit(keyword) {
document.location="http://www.mysite.co.uk/compareprices/" + keyword + ".htm";
}
</script>
The problem i have now is if you enter a 2 or more word search you have a space between the words. I cant figure out how to replace the space for example a search for "blue widget" would take you to:
www.mysite.co.uk/compareprices/blue%20widget.htm

I want to replace this space to get:
www.mysite.co.uk/compareprices/blue-widget.htm

Thanks

William

Last edited by William M; Oct 4th, 2007 at 15:45.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 4th, 2007, 16:02
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help With Search Box/form

Use the replace function.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form output using mysql, search people name in specific category basketmen PHP Forum 1 Mar 24th, 2008 06:31
[SOLVED] Form Search longstand PHP Forum 6 Nov 20th, 2007 06:13
Anyone have a working search form script? daveg33 PHP Forum 12 Sep 28th, 2007 23:54
Search Analyst/Account Executive/SEO/PPC/CPC/Search Engine Optimisation/Pay per Click/London Web JobBot Job Opportunities 0 Nov 22nd, 2006 10:20
Advanced search form victory Classic ASP 1 Mar 4th, 2005 20:57


All times are GMT. The time now is 18:38.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42