Solved

Add a hidden term to search

Posted on 2004-08-25
11
195 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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell script does not exit 4 45
Validating Date Part2 2 25
ASP sending two datas 2 22
Compute age Html 2 23
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Find out what you should include to make the best professional email signature for your organization.
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

685 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