SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: How to always add some extra hidden text to what is submitted through a Form?

  1. #1
    SitePoint Zealot
    Join Date
    Oct 2012
    Posts
    108
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    How to always add some extra hidden text to what is submitted through a Form?

    I am working with a Search Box that I want to only search a specific site. To get it to do that I need to add the following to the front of each search query site:www,mysite,com
    (I used commas just to keep it from showing here as an UL)

    This is just like what people would do from one of the major search engines IF they new that adding site:www,mysite,com to their query would limit the results to only that site's results

    Here is a sample of the current code:

    <form class="navbar-search" method="get" action="http://www.searchengine.com/search" >
    <input type="text" name="query">
    </form>

    Basically I just want to automatically always add or apend this text site:www,mysite,com to "query" when it is submitted. Is this possible? How???

  2. #2
    It's all Geek to me silver trophybronze trophy
    SitePoint Award Recipient ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, Australia
    Posts
    19,978
    Mentioned
    216 Post(s)
    Tagged
    2 Thread(s)
    Is this a Google search? If so, you can get the form code from Google itself.

    Code:
    <form method="get" action="http://www.google.com/search">
      <label for="q">Search this Site</label> 
      <input type="text" name="q" id="q" value=""> 
      <input type="submit" value="Search">
      <input type="hidden" name="sitesearch" value="mysite.com">
    </form>

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2012
    Posts
    108
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi Ralph, thanks for the quick response!

    Your code works great - but unfortunately I think it is a backdoor way of getting "Google Site Search" which is supposed to cost $100 a year. See http://www.google.com/enterprise/sea...ducts_gss.html

    We can't afford to piss off the Google monster

    I'm looking for something that can be used with any smaller alternative searchengine that allows having the search result narrowed to a particular site...

  4. #4
    It's all Geek to me silver trophybronze trophy
    SitePoint Award Recipient ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, Australia
    Posts
    19,978
    Mentioned
    216 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Greg Baka View Post
    I think it is a backdoor way of getting "Google Site Search" which is supposed to cost $100 a year.
    That's if you want the customized version, but there's nothing wrong with using the code I posted. It's just a bit of a plain experience, but there's not problem using it. It's provided by Google.
    Last edited by guido2004; Oct 23, 2012 at 07:27. Reason: corrected quote tag

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •