Solved

Add a hidden term to search

Posted on 2004-08-25
11
187 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Zoom the page when you go in from your phone 3 53
Input box width 6 25
Html5 Index on a table 7 25
Create CSS Animation for Page Transitions 4 24
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses four methods for overlaying images in a container on a web page
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now