Solved

Add a hidden term to search

Posted on 2004-08-25
11
203 Views
Last Modified: 2012-05-05
Hi

1.How can i add an unseen search term to one of these searches, so that for instance the first search is always loaded with the word "html" but the user cant see this.
Whatever keywords they add are added to "html" and the search looks for all of them.

2.How can I do this with more than one hidden term eg, "html" and "learn"

3.And can these terms be labelled as something other than "keywords" so that the search results don' t say, eg if the search term was 'div'
Results for html learn div...BUT
Results for div
--as the search is set up to say "Results for 'keywords' "

 - putting my last current lot of points up.

Thanks
====================
<form method="get">


  <table width="98%" border="0" align="center">
    <tr>
      <td> <div align="right">
          <input type="hidden" name="keywords">
     
          <input type="text" name="search" size="20" maxlength="255">
        </div></td>
      <td><div align="left">

          <input type="submit" style="width:110;text-align:center" value="Web Search" onclick="this.form.keywords.value = this.form.search.value; this.form.action = ' http://www.search.com/cgi-bin/search/search.cgi?keywords ';">

          <input type="submit" style="width:110;text-align:center" value="Directory" onclick="this.form.keywords.value = this.form.search.value; this.form.action = ' http://www.search.com/cgi-bin/dirr/search/search.cgi?keywords ';">

                 </div></td>
    </tr>
  </table>

</form>
0
Comment
Question by:macuser777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 8

Expert Comment

by:trevorhartman
ID: 11897929
If you are using search.com's search engine, there is no way to control what it displays.  If you submit keywords to it, it will display them.  Do you still need help figuring how to append "html" to the beginning of your search term?
0
 
LVL 4

Author Comment

by:macuser777
ID: 11897955
I am using a product called smartsearch. I just put search in for example.

http://smarterscripts.com/smartsearch/

i'm playing with the script to try and make it a more focused search.

0
 
LVL 4

Author Comment

by:macuser777
ID: 11898520
..so yes help still required...appending terms would be a start anyway...
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 8

Expert Comment

by:trevorhartman
ID: 11898920
use a onSubmit event handler for your form, and append whichever keywords you want to the beginning of the input
0
 
LVL 4

Author Comment

by:macuser777
ID: 11899761
>>>      use a onSubmit event handler for your for your form, and append whichever keywords you want to the beginning of the input.

Can you supply an example of what you mean please.

0
 
LVL 8

Expert Comment

by:trevorhartman
ID: 11903814
<script>
function addTerms()
{
 document.forms[0].search.value = 'html ' + document.forms[0].search.value;
 return true;
}
</script>
<form method="get" onSubmit="addTerms()">


  <table width="98%" border="0" align="center">
    <tr>
      <td> <div align="right">
          <input type="hidden" name="keywords">
     
          <input type="text" name="search" size="20" maxlength="255">
        </div></td>
      <td><div align="left">

          <input type="submit" style="width:110;text-align:center" value="Web Search" onclick="this.form.keywords.value = this.form.search.value; this.form.action = ' http://www.search.com/cgi-bin/search/search.cgi?keywords ';">

          <input type="submit" style="width:110;text-align:center" value="Directory" onclick="this.form.keywords.value = this.form.search.value; this.form.action = ' http://www.search.com/cgi-bin/dirr/search/search.cgi?keywords ';">

                 </div></td>
    </tr>
  </table>

</form>
0
 
LVL 4

Author Comment

by:macuser777
ID: 11905047
My question asks for a hidden term to be added to ONE of the searches. This code adds it to both.

Also my qusetion asks for it to be a hidden term - this puts the added terms into the input box.
0
 
LVL 8

Expert Comment

by:trevorhartman
ID: 11905058
ok, this is because only 1 input can be submitted to the search.  I will get an example that allows it to be hidden.
0
 
LVL 8

Accepted Solution

by:
trevorhartman earned 80 total points
ID: 11914710
<form method="get">


  <table width="98%" border="0" align="center">
    <tr>
      <td> <div align="right">
          <input type="hidden" name="keywords">
     
          <input type="text" name="search" size="20" maxlength="255">
        </div></td>
      <td><div align="left">

          <input type="submit" style="width:110;text-align:center" value="Web Search" onclick="this.form.keywords.value = 'html' + this.form.search.value; this.form.action = ' http://www.search.com/cgi-bin/search/search.cgi?keywords ';">

          <input type="submit" style="width:110;text-align:center" value="Directory" onclick="this.form.keywords.value = this.form.search.value; this.form.action = ' http://www.search.com/cgi-bin/dirr/search/search.cgi?keywords ';">

                 </div></td>
    </tr>
  </table>
</form>
0
 
LVL 4

Author Comment

by:macuser777
ID: 11923432
Hi

That works well for my first 2 requests - very well actually. Thanks.

With regards to renaming the hidden term something other than 'keywords' - I guess that's probably another Q.

I'll leave it open for a while just in case - otherwise i'll ask that part in another q.

Thanks again

macuser
0
 
LVL 4

Author Comment

by:macuser777
ID: 11950894
thanks for your help :)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question