Virginia Commonwealth University

Richmond, Va.

How do I add the VCU ht:/Dig Search to my web site?

Two options are presented to assist you in adding a search feature to your departmental web site.

 

 Option 1:  Search Your Department Web


This search feature searches only your departmental web site. It matches all the keywords and displays a detailed summary of responses sorted in highest ranking order.  This option uses only HTML code which can be placed most anywhere within the <body> of your web page.

The following code will produce a search that looks like this:

Search: submitsearch  

HTML Code:  {insert this form into the body of your HTML page}

 <form action="http://search.vcu.edu/cgi-bin/htsearch" method="post" name="searchfaq" id="searchfaq">
<label for="words" class="unnamed1"></label>
<span class="unnamed1">Search:</span>
<input name="words" type="text" class="searchbox" id="words" size="15">
<input type="hidden" name="restrict" value="deptURL">
<a href="javascript:document.searchfaq.submit()">
<img src="/web/images/s_search.gif"
alt="submitsearch" border="0" width="23" height="14"></a>&nbsp;&nbsp;
</form>
 

For Web Support Services, deptURL is

http://www.vcu.edu/web/

which is the directory that contains all of the web pages for Web Support Services.



 Option 2:  Search Multiple Web Sites


The second option searches the online phone directory, your departmental web, the VCU web and the Internet (using the Alta Vista search engine). It matches all the keywords and displays a detailed summary of responses sorted in highest ranking order.  This option uses both JavaScript and HTML code.  The JavaScript must be placed in the <header> of your web page and the HTML code is placed most anywhere within the <body> of your web page.  

The following code will produce a search that look like this:

Search

Options

JavaScript Code:  {insert the JavaScript into the <head> of your HTML page}

<script language="javascript">

function checkQuery() {
  var queryFld = document.keyword.query
  if (queryFld.value == "") {
    alert ("Please enter a query")
    queryFld.focus()
    return(false)
    }
  return(true)
  }

function checkName() {
  var nameFld = document.ccso.NAME
  if (nameFld.value == "") {
    alert ("Please enter a name")
    nameFld.focus()
    return(false)
    }
  return(true)
  }

function convertString( temp ) {
  var newString = "";
  var i=0;
  for( i=0; i < temp.length; i++ ) {
    if( temp.charAt(i) != " " ) {
      newString += temp.charAt(i);
      }
    else {
      newString += "+";
      }
    }
  return newString;
  }

function startSearch() {

  //people
  if( document.keyword.searchnav.selectedIndex == 0 ) {
    if( checkQuery() ) {
      var header = "http://search.vcu.edu/cgi-bin/directall?"
      options = "TYPE=All";
      searchVal = "&NAME=" + convertString(document.keyword.query.value);
      eval( "location = " + "\"" + header + options + searchVal + "\"" );
      }
    }

  //vcu via HtDig
  if( document.keyword.searchnav.selectedIndex == 1 ) {
    if( checkQuery() ) {
      var header = "http://search.vcu.edu/cgi-bin/htsearch?";
      var options = "config=htdig&restrict=";
      var restrict = "";
      var options2 = "&method=and&format=builtin-long&sort=score";
      var searchVal = "&words=" + convertString(document.keyword.query.value);
      eval( "location = " + "\"" + header + options + restrict + options2 + searchVal + "\"");
      }
    }

  //Internet via AltaVista
  if( document.keyword.searchnav.selectedIndex == 2 ) {
    if( checkQuery() ) {
      var header = "http://www.altavista.com/cgi-bin/query?";
      var options = "sc=on&pg=q&kl=XX";
      var searchVal = "&q=" + convertString(document.keyword.query.value);
      eval( "location = " + "\"" + header + options + searchVal + "\"");
      }
    }

  //DEPT via HTDIG
  if( document.keyword.searchnav.selectedIndex == 3 ) {
    if( checkQuery() ) {
      var header = "http://search.vcu.edu/cgi-bin/htsearch?";
      var options = "config=htdig&restrict=";
      var restrict = "deptURL";
      var options2 = "&method=and&format=builtin-long&sort=score";
      var searchVal = "&words=" + convertString(document.keyword.query.value);
      eval( "location = " + "\"" + header + options + restrict + options2 + searchVal + "\"");
      }
    }
  }

</script>
 

HTML Code:  {insert this form into the <body> of your HTML page}

<form name="keyword" action="" onSubmit="startSearch();return false">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<b>Search</b><br>
</font>
<label for="search"></label>
<input type="text" id="search" name="query" size="15" maxlength="40"><br>
<label for="select"></label>
<select id="select" name="searchnav" size="1">
<option value="people" selected>People</option>
<option value="vcu">VCU Web</option>
<option value="internet">Internet</option>
<option value="DEPT">Department</option>
</select>
<input type="submit" name="Submit" value="Go">
<a href="http://www.vcu.edu/search/">
<font face="Verdana" size="1">
<br> Options
</font>
</a>
</form>
 

For Web Support Services, deptURL is

http://www.vcu.edu/web/

This is the directory which contains all of the web pages for Web Support Services. Note: You can arrange the choices in any order that you would like but you must modify the JavaScript accordingly.