Error:对象不支持此属性或方法

时间:2023-01-02 09:04:56
function GrabNumber(){ 

var urlXML='search.php?q='+ document.form1.user.value;
var urlXSL='search.xsl';
var newImg=document.createElement('img')
newImg.setAttribute('src','../images/loading2.gif');
document.getElementById("results").appendChild(newImg);
LoadXMLXSLTDoc(urlXML,urlXSL,"results");
<!--合并XSLT和XML文档-->
var xmlDoc;
var xslDoc;
var objOutput;
function LoadXMLXSLTDoc(urlXML,urlXSL,elementId){
xmlDoc=null;
xslDoc=null;
objOutput=document.gerElementById(elementId);
new net.ContentLoader(urlXML,onXMLLoad);
new net.ContentLoader(urlXSL,onXSLLoad);
}
function onXMLLoad(){
xmlDoc=this.req.responseXML;
doXSLT();
}
function onXSLLoad(){
xslDoc=this.req.responseXML;
doXSLT();
}
function doXSLT(){
if(xmlDoc==null||xslDoc==null){return;}
if(window.ActiveXObject){
objOutput.innerHTML=xmlDoc.transformNode(xslDoc);
}
else{
var xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xslDoc);
var fragment =xsltProcessor.transformToFragment(xslDoc,document);
objOutput.innerHTML="";
objOutput.appendChild(fragment);
}
 }
 }
</script>

</head>

<body>
<form name="form1" id="form1" onsubmit="GrabNumber();return false;">
Name:<input type="text" name="user" />
<input type="submit" name="search" value="搜索" />
<br /> <br />
<div id="results"></div>
</form>


</body>
</html>
后台的
search.php
<?xml version="1.0" ?>
  <display>
  <entry>
  <name>alu_name</name>
  <sex>alu_sex</sex>
  <school>alu_school</school>
  <specility>alu_specility</specility>
  <timeru>alu_timeru</timeru>
  <timechu>alu_timechu</timechu>
  <grade>alu_grade</grade>
  <company>alu_company</company>
  <job>alu_job</job>
  </entry>
  </display>
  
<!--12-4-->  
  <?xml version="1.0" ?>
  <display>
  <entry>
  <name>no results</name>
  <sex>N/A</sex>
  <school>N/A</school>
  <specility>N/A</specility>
  <timeru>N/A</timeru>
  <timechu>N/A</timechu>
  <grade>N/A</grade>
  <company>N/A</company>
  <job>N/A</job>
  </entry>
  </display>
 <!--12-5服务器端生成XML--> 
  <?php
  header("content-type:text/xml");
  echo("<?xml version='1.0' ?>\n");
  $db=mysqi_connect("localhost","xpp","368");
  mysql_select_db("alumni",$db);
  $result=mysql_query("select 校友姓名,性别,学校名称,所学专业,入学时间,毕业时间,学历,工作单位,职务职称
from allname where 校友姓名 like '%".$_GET['q']."%'",$db);
  ?>
  <display>
  <?
  if($myrow=mysql_fetch_array($result)){
  do{
  ?>
  <entry id='<?=$myrow['id']?>001'>
  <name><?=$myrow['alu_name']?></name>
  <sex><?=$myrow['alu_sex']?></sex>
  <school><?=$myrow['alu_school']?></school>
  <specility><?=$myrow['alu_specility']?></specility>
  <timeru><?=$myrow['alu_timeru']?></timeru>
  <timechu><?=$myrow['alu_timechu']?></timechu>
  <grade><?=$myrow['alu_grade']?></grade>
  <company><?=$myrow['alu_company']?></company>
  <job><?=$myrow['alu_job']?></job>
  </entry>
  <?
  }while($myrow=mysql_fetch_array($result));
  }else{
  ?>
  <entry id='001'>
  <name>no results</name>
  <sex>N/A</sex>
  <school>N/A</school>
  <specility>N/A</specility>
  <timeru>N/A</timeru>
  <timechu>N/A</timechu>
  <grade>N/A</grade>
  <company>N/A</company>
  <job>N/A</job>
  </entry>
  <?
  }
  ?>
  </display>
  
 <!--12-6XSLT文件--> 
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/">
 <table id="table1">
 <tr>
 <th align="left">校友姓名</th>
 <th align="left">性别</th>
  <th align="left">学校名称</th>
  <th align="left">所学专业</th>
 <th align="left">入学时间</th>
  <th align="left">毕业时间</th>
<th align="left">学历</th>
<th align="left">工作单位</th>
<th align="left">职务职称</th>
</tr>
<xsl:for-each
select="display/entry">
<tr>
<td><xsl:value-of
select="name"/></td>
<td><xsl:value-of
select="sex"/></td>
<td><xsl:value-of
select="school"/></td>
<td><xsl:value-of
select="spacility"/></td>
<td><xsl:value-of
select="timeru"/></td>
<td><xsl:value-of
select="timechu"/></td>
<td><xsl:value-of
select="grade"/></td>
<td><xsl:value-of
select="company"/></td>
<td><xsl:value-of
select="job"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

1 个解决方案

#1


这个提示很说明问题了。

#1


这个提示很说明问题了。