• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

has no properties...

I am working on this page below - using dreamweaver.  When I run it from my pc I have no problems and the search script works fine.  When I put it on the server it does not work and i get the message:
document.forms[0].query.value has no properties.  The .js file records is in the same directory on my pc and on the server.

Thanks


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>SRI Library - Archiving and Research - Main Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!--#include virtual="/topjs.shtml" -->
<link rel="stylesheet" href="/style.css">
<style type="text/css">
<!--


.menutxt{
color:#333333;
}

.toptext{
font-size:16px;
font-weight:bold;
}
.itsar{
font-size:20px;
font-weight:bold;
}
A.menu {
color:#0000FF;
text-decoration:none;
}
A.menusmall {
color:#0000FF;
text-decoration:none;
}

A.menu:hover {
color:red;
}
A.alpha{
text-decoration:none;
}
A.alpha:hover{
color:red;
}
.menudiv {

background-color:#ffffcc;
width:147px;
}

-->
</style>
<script LANGUAGE="JavaScript1.1" SRC="records.js"></SCRIPT>
<script LANGUAGE="JavaScript1.1">
<!--

function show(jid)
{
document.getElementById(jid).style.visibility = "visible";
}
function hide(hjid)
{
document.getElementById(hjid).style.visibility="hidden";
}
function strip(str) {

   var re = /\s?of\s+|\s?the\s+|\s?and\s+|\s?an\s+\s?a\s+|&|\.|journal/gi;
   str=str.toLowerCase();
   str=str.replace(re,"");
   str = str.split(" ").join("");
   return(str);
   


}



// Define global variables
var SEARCHANY     = 1;
var SEARCHALL     = 2;
var SEARCHURL     = 4;
var searchType  = '';
var showMatches   = 10;
var currentMatch  = 0;
var copyArray   = new Array();


// Determine the type of search, and make
// sure the user has entered something
function validate(entry) {
if (document.getElementById)
      {
            x = document.getElementById("result");
            x.innerHTML = '';
            
            
      }
      else if (document.all)
      {
            x = document.all["result"];
            
      }


  if (entry.charAt(0) == "+") {
    entry = entry.substring(1,entry.length);
    searchType = SEARCHALL;
    }
  else if (entry.substring(0,4) == "url:") {
    entry = entry.substring(5,entry.length);
    searchType = SEARCHURL;
    }
  else { searchType = SEARCHANY; }
  while (entry.charAt(0) == ' ') {
    entry = entry.substring(1,entry.length);
    document.forms[0].query.value = entry;
    }
  while (entry.charAt(entry.length - 1) == ' ') {
    entry = entry.substring(0,entry.length - 1);
    document.forms[0].query.value = entry;
    }
  if (entry.length < 3) {
    alert("You cannot search strings that small. Elaborate a little.");
    document.forms[0].query.focus();
    return;
    }
  entry = strip(entry);
  convertString(entry);
  }

// Put the search terms in an array and
// and call appropriate search algorithm
function convertString(reentry) {
  var searchArray = reentry.split(" ");
  if (searchType == (SEARCHANY | SEARCHALL)) { requireAll(searchArray); }
  else { allowAny(searchArray); }
  }

// Define a function to perform a search that requires
// a match of any of the terms the user provided
function allowAny(t) {
  var findings = new Array(0);
  for (i = 0; i < profiles.length; i++) {
    var compareElement  = profiles[i].toUpperCase();
    if(searchType == SEARCHANY) { var refineElement  = compareElement.substring(0,compareElement.indexOf('|HTTP')); }
    else { var refineElement = compareElement.substring(compareElement.indexOf('|HTTP'), compareElement.length); }
    for (j = 0; j < t.length; j++) {
      var compareString = t[j].toUpperCase();
      if (refineElement.indexOf(compareString) != -1) {
        findings[findings.length] = profiles[i];
        break;
        }
      }
    }
  verifyManage(findings);
  }

// Define a function to perform a search that requires
// a match of all terms the user provided
function requireAll(t) {
  var findings = new Array();
  for (i = 0; i < profiles.length; i++) {
    var allConfirmation = true;
    var allString       = profiles[i].toUpperCase();
    var refineAllString = allString.substring(0,allString.indexOf('|HTTP'));
    for (j = 0; j < t.length; j++) {
      var allElement = t[j].toUpperCase();
      if (refineAllString.indexOf(allElement) == -1) {
        allConfirmation = false;
        continue;
        }
      }
    if (allConfirmation) {
      findings[findings.length] = profiles[i];
      }
    }
  verifyManage(findings);
  }

// Determine whether the search was successful
// If so print the results; if not, indicate that, too
function verifyManage(resultSet) {
  if (resultSet.length == 0) { noMatch(); }
  else {
    copyArray = resultSet.sort();
    formatResults(copyArray, currentMatch, showMatches);
    }
  }

// Define a function that indicates that the returned no results
function noMatch() {
 
  x.innerHTML =
    '<TABLE WIDTH=90% BORDER=0 ALIGN=CENTER><TR><TD VALIGN=TOP><FONT FACE=Arial><B><DL>' +
    '<HR NOSHADE WIDTH=100%>"' + document.forms[0].query.value +
    '" returned no results.<HR NOSHADE WIDTH=100%></TD></TR></TABLE>';
 
  document.forms[0].query.select();
  }

// Define a function to print the results of a successful search
function formatResults(results, reference, offset) {
  var currentRecord = (results.length < reference + offset ? results.length : reference + offset);

/*  x.innerHTML =
    '<TABLE WIDTH=90% BORDER=0 ALIGN=CENTER CELLPADDING=3><TR><TD>' +
    '<HR NOSHADE WIDTH=100%></TD></TR><TR><TD VALIGN=TOP><FONT FACE=Arial><B>' +
    'Search Query: <I>' + document.forms[0].query.value + '</I><BR>\n' +
    'Search Results: <I>' + (reference + 1) + ' - ' +
    currentRecord + ' of ' + results.length + '</I><BR><BR></FONT>' +
    '<FONT FACE=Arial SIZE=-1><B>' + '\n\n<!-- Begin result set //-->\n\n\t<DL>'; */
  if (searchType == SEARCHURL) {
    for (var i = reference; i < currentRecord; i++) {
      var divide = results[i].split("|");
      x.innerHTML += divide[2] +  divide[2]
     + divide[1];
      }
    }
  else {
    for (var i = reference; i < results.length; i++) {
      var divide = results[i].split('|');
      
    x.innerHTML += '<A HREF="' + divide[2] + '">' + divide[0] + '</A>';
      /*  '<I>' + divide[1] + '<br>'; */
      }
    }
/* x.innerHTML +='\n\t</DL>\n\n<!-- End result set //-->\n\n';
  prevNextResults(results.length, reference, offset);
  x.innerHTML += '<HR NOSHADE WIDTH=100%>' +
    '</TD>\n</TR>\n</TABLE>\n</BODY>\n</HTML>';
  document.forms[0].query.select(); */
  }

// Define a function to dynamically display Prev and Next buttons
/*function prevNextResults(ceiling, reference, offset) {
  x.innerHTML += '<CENTER><FORM>';
  if(reference > 0) {
    x.innerHTML += '<INPUT TYPE=BUTTON VALUE="Prev ' + offset + ' Results" ';
      'onClick="document.layers["content"].formatResults(document.layers["content"].copyArray, ' +
      (reference - offset) + ', ' + offset + ')">';
    }
  if(reference >= 0 && reference + offset < ceiling) {
    var trueTop = ((ceiling - (offset + reference) < offset) ? ceiling - (reference + offset) : offset);
    var howMany = (trueTop > 1 ? "s" : "");
    x.innerHTML = '<INPUT TYPE=BUTTON VALUE="Next ' + trueTop + ' Result' + howMany + '" ' +
      'onClick="document.["content"].copyArray, ' +
      (reference + offset) + ', ' + offset + ')">';
    }
  x.innerHTML = '</CENTER>';
  }
 */

//-->
</SCRIPT>

</head>

<body bgcolor="#FFFFFF" style=" margin-top:0; margin-left:0; margin-right:0;" onLoad="document.search.query.focus()">
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr valign="top"> <td>
<!--#include virtual="/its/includes/top0.shtml" -->
</td></tr>
</table>
<div id="menu" class="menudiv" style="position:absolute; vertical-align:top; left:0; margin-left:2px;">
<br>&nbsp;<a class="menu" href="https://insider.sri.com/its/library/test/journals/ejournals.html">Journals +</a>
<br>&nbsp;<a class="menu" href="https://insider.sri.com/its/library/test/databases/onlinedatabases.html">Databases +</a>
<br>&nbsp;<a class="menu" href="https://insider.sri.com/its/library/test/documentdelivery/request.html">Doc. Delivery +</a>
<br>&nbsp;<a class="menu" href="https://insider.sri.com/its/library/test/catalog/basic.html">Library Catalog +</a>
<br>&nbsp;<a class="menu" href="https://insider.sri.com/its/library/test/records/info.html">Records Center +</a>
<br>&nbsp;<a class="menu" href="https://insider.sri.com/its/library/test/contact/staff.html">Contact us +</a>
<br>&nbsp;<a class="menu" href="https://insider.sri.com/its/library/test/help/servicesatoz.html">Help +</a>
<br><br>
</div>

<div style="margin:0px 10px 50px 200px; padding:10px;">
<p class="bread"><!--#exec cmd="/ns-home/docs/intranet/production/cgi-bin/breadcrumb.pl" --></p>
<font class="itsar">SRI Library ITS - Archiving and Research</font><font class="toptext"><br>
    Locations:</font><br>
   Main Library: AG001<br>
    Main Library Annex: BS020<br>
  Life Sciences Library: Building 100<br>
  Life Sciences Storage: BN061
   <br>
    Records Center: BS013<br>
    <br>
    If you have questions please call x2634 or email Library@sri.com,<br>
   
<br>
<br>
<div>
  <table WIDTH="40%" BORDER="0">
<tr>
  <td>
  <form NAME="search" id="search" onsubmit="validate(document.forms[0].query.value); return false;">
  Search for E-journals<br>
    <input type=TEXT id="query" name="query" size="33">&nbsp;&nbsp;<a href="" style="text-decoration:none; "
       onClick="validate(document.forms[0].query.value); return false;">Search</a>
  </form>
  <div id="result" style= "max-height:170px;overflow:auto"></div>
  </td>
</tr>
</table>
<br>
<br>
</div>


<p align="center"><a href="/cgi-bin/comments.pl">Comments, Questions
and Feedback</a><br>
&copy; SRI International - For internal SRI use only</p>
       
     
     
   



<br>
<br>
<!--#include virtual="/services/includes/bottom.shtml" -->
</div>
</body>
</html>



0
worldfear
Asked:
worldfear
1 Solution
 
BatalfCommented:
Are there more than one form on the page? Maybe you should use form name in your function call.

ie. change

onClick="validate(document.forms[0].query.value); return false;">

to

onClick="validate(document.search.query.value); return false;">

Batalf

0
 
worldfearAuthor Commented:
thanks batalf, i realized just after i posted this that there is a form in the server side include that sits in the header.

i tried to delete the post but you were too fast...

0

Featured Post

Technology Partners: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now