请关注我,因为我不是程序员,但我有一个公司内部网搜索站点,它在特定数据库中搜索对象并返回结果表。我所关注的元数据标签基本上是“类型”,“名称”和“修订版”。在这个数据库中,我们可能会使用“Type A”,“Type B”和“Type C”捕获相同的文档,其中Name和Rev对于这三个都是相同的。
目前,当您通过htm站点提交“名称”搜索时,JSP配置为返回所有类型,但仅返回最新/最新版本。我想修改编码(最好是在htm中,如果可能的话),也要优先考虑类型,以及它们是否像修订版一样按顺序排列(转1,2,3等)。
例如:如果搜索找到两个具有相同名称和rev的项目,我只希望显示类型A并忽略类型B和C. 如果类型A不存在,或者没有有效的文件链接,则搜索结果应仅显示类型B. 如果A和B不存在,再次显示C型。
如果可以在htm函数或变量中实现这些想法吗?或者这是否必须在htm引用的JSP中进行编码?
<HTML><HEAD>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<SCRIPT type=text/javascript>
function setHiddenValues()
{
var index = document.thedatabase_search.Document_Type.options.length;
var type="";
for(var i=0;i<index;i++)
{
if(document.thedatabase_search.Document_Type.options[i].selected)
{
if (type=="")
{
type = eval("document.thedatabase_search.Document_Type.options["+i+"].text");
}
else
{
type = type + "," + eval(""document.thedatabase_search.Document_Type.options["+i+"].text");
}
}
}
document.thedatabase_search.type.value=type;
var revisionOptions = document.getElementsByName("radio1");
var selectedRev = "";
for(var j = 0; j < revisionOptions.length; j++)
{
if(revisionOptions[j].checked)
{
selectedRev = revisionOptions[j].value;
}
}
if (selectedRev=="Specified")
{
document.thedatabase_search.revision.value=document.thedatabase_search.Document_Revision.value;
}
else
{
document.thedatabase_search.revision.value=selectedRev;
}
var docName = document.thedatabase_search.Document_Name.value;
if (docName=="" || docName == "*")
{
alert("Please specify Name");
return false;
}
if (document.thedatabase_search.Document_Name.length < 2)
{
alert("Atleast two characters should be specified in Name field");
return false;
}
if (document.thedatabase_search.Document_Revision.value=="")
{
alert("Please specify revision");
return false;
}
//document.thedatabase_search.Document_Name.value = document.thedatabase_search.Document_Name.value + "*";
//document.thedatabase_search.Document_Title.value = document.thedatabase_search.Document_Title.value + "*";
var trimmedName = docName.replace(/^\s+|\s+$/g, '');
if (trimmedName.length<2||trimmedName.substring(0,1)=="*"||trimmedName.substring(1,2)=="*")
{
alert("Atleast two characters should be specified in Name field\nThe first two characters of Name field cannot be '*'");
return false;
}
if (trimmedName.slice(-1)!="*")
{
document.thedatabase_search.Document_Name.value=trimmedName.concat("*");
}
var docTitle = document.thedatabase_search.Document_Title.value;
var trimmedTitle = docTitle.replace(/^\s+|\s+$/g, '');
if (trimmedTitle == "")
{
//do nothing
}
else if (trimmedTitle.length == 1 && trimmedTitle == "*")
{
//do nothing
}
else if (trimmedTitle.length == 1 && trimmedTitle != "*")
{
alert("Atleast two characters should be specified in Title field\nThe first two characters of Title field cannot be '*'");
return false;
}
else if (trimmedTitle.length >= 2)
{
if (trimmedTitle.substring(0,1)=="*"||trimmedTitle.substring(1,2)=="*")
{
alert("Atleast two characters should be specified in Title field\nThe first two characters of Title field cannot be '*'");
return false;
}
}
if (trimmedTitle.slice(-1)!="*")
{
document.thedatabase_search.Document_Title.value=trimmedTitle.concat("*");
}
document.thedatabase_search.name.value=document.thedatabase_search.Document_Name.value;
document.thedatabase_search.short_description.value=document.thedatabase_search.Document_Title.value;
document.thedatabase_search.current.value=document.thedatabase_search.Document_State.value;
document.thedatabase_search.action="/documentSearch/DocumentSearchResults.jsp";
document.thedatabase_search.method = "post";
document.thedatabase_search.submit();"
}
function enableRevisionField()
{
document.thedatabase_search.Document_Revision.disabled=false;
document.thedatabase_search.Document_Revision.value="";
}
function disableRevisionField()
{
document.thedatabase_search.Document_Revision.disabled=true;
document.thedatabase_search.Document_Revision.value='disabled';
}
function disableRevisionAndStateField()
{
document.thedatabase_search.Document_Revision.disabled=true;
document.thedatabase_search.Document_Revision.value='disabled';
document.thedatabase_search.Document_State.disabled=true;
document.thedatabase_search.Document_State.value='disabled';
}
function clearFormValues()
{
document.thedatabase_search.Document_Name.value="";
document.thedatabase_search.Document_Title.value="";
document.thedatabase_search.name.value="";
document.thedatabase_search.short_description.value="";
}
</SCRIPT>
<META name=GENERATOR content="MSHTML 8.00.7601.18305"></HEAD>
<BODY onLoad="document.thedatabase_search.Document_Name.focus()"><BR><BR>
<HR>
<B>
<CENTER><FONT face=arial size=5>This is the Search Header</FONT></CENTER></B>
<HR>
<FORM onsubmit="return setHiddenValues()" name=thedatabase_search><!-- Value used in jsp page - STARTS -->
<!-- type should be of form TypeA,TypeB,TypeC -->
<!-- company should not edit this line -->
<INPUT type=hidden name=type>
<!-- revision can be one of the following
revision = A or B or any valid value in objects revision chain
revision = All
revision = Latest
revision = Latest_Released
revision = Highest_By_State -->
<!-- company should not edit revision here -->
<INPUT type=hidden name=revision>
<!-- name can have wildcard characters Example: Test* -->
<!-- company should not edit revision here -->
<INPUT type=hidden name=name>
<!-- current can have any State value from the list Example: Preliminary -->
<!-- company should not edit revision here -->
<INPUT type=hidden name=current>
<!-- short_description can have wildcard characters Example: Test* -->
<!-- company should not edit revision here -->
<INPUT type=hidden name=short_description>
<!-- user should be a single value; This a mandatory -->
<!-- company should edit this line and provide proper account to be used Based on this account name the key file will be generated for the division by corporate-->
<INPUT value=DocSearchUser type=hidden name=user>
<!-- results_field - the columns to be present in resulst page;The results table will show values in the order specified here
Acceptable values - Type, Name, Revision, State, Short_Description, FileLink, Owner, Originator,Originated, Modified, Release_Date
companies may edit this line to add or remove fields from the Acceptable values -->
<INPUT value=Type,Name,Revision,Short_Description,State,FileLink type=hidden name=results_field>
<!-- Value used in jsp page - ENDS -->
<!-- company may edit this to specify their own title to appear in the search results page here -->
<INPUT value="Search Results" type=hidden name=title>
<TABLE border=1 width=500 align=center>
<TBODY>
<TR>
<TD height=40 width=200><B>Document Name<B></B></B></TD>
<TD><INPUT name=Document_Name></TD></TR>
<TR>
<TD height=60><B>Document Type</B></TD>
<TD><SELECT id=Document_Type multiple size=3 name=Document_Type>
<OPTION selected value="TypeA">TypeA</OPTION>
<OPTION selected value="TypeB">TypeB</OPTION>
<OPTION selected value="TypeC">TypeC</OPTION>
<OPTION value=*>All</OPTION></SELECT> </TD></TR>
<TR>
<TD height=50><B>Document Revision<B></B></B></TD>
<TD><INPUT disabled value=disabled name=Document_Revision>
<TABLE border=0>
<TBODY>
<TR>
<TD><INPUT id=Latest onclick=disableRevisionField()
value=Latest CHECKED type=radio name=radio1> <LABEL for=Latest>Latest</LABEL></TD></TR>
<TR>
<TD><INPUT id=Latest_Released onclick=disableRevisionAndStateField()
value=Latest_Released type=radio name=radio1> <LABEL for=Latest_Released>Latest Released</LABEL></TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD height=40><B>Document Title</B></TD>
<TD><INPUT name=Document_Title></TD>
</TR>
<TR>
<TD height=40><B>State</B></TD>
<TD><SELECT id=Document_State name=Document_State>
<OPTION selected value=*>*</OPTION>
<OPTION value=Preliminary>Preliminary</OPTION>
<OPTION value=Review>Review</OPTION>
<OPTION value=Approved>Approved</OPTION>
<OPTION value=Release>Release</OPTION>
<OPTION value=Obsolete>Obsolete</OPTION></SELECT> </TD></TR>
</TBODY></TABLE><BR><BR>
<CENTER><INPUT value=Submit type=submit> </CENTER></FORM></BODY></HTML>