我的剧本
function fnsort(firstname)
{
alert("hi")
alert( $('#hidetxt').val().length);
if($('#hidetxt').val().length ==0 )
{
$("#hidetxt").val("firstname Asc");
// alert( $('#hidetxt').val());
loadval();
alert("asc function")
}
else
{
var str="firstname Asc";
var n=str.split(" ");
if(n[0] == "firstname")
{
$("#hidetxt").val("firstname Desc");
alert("desc function")
$('#hidetxt').val("")
}
else
{
alert("Control is wrong")
}
}
/*document.getElementById('form2').action="display_report.cfm";
document.getElementById('form2').submit(); */
}
function loadval()
{
<cfoutput>
<cfquery name="result" datasource="Training">
select TE.firstname,TE.lastname,TD.deparmentname,TE.salary,TE.DateOfBirth
from TEmployee as TE
inner join Tdepartment as TD
on TE.departmentID=TD.departmentID
where 1 = 1
<cfif len(form.fname) gt 0 >
AND TE.FirstName Like '#Form.fname#%'
</cfif>
<cfif len(form.lname) gt 0>
and TE.LastName Like '#Form.lname#%'
</cfif>
<cfif form.dept neq 0>
and TD.DeparmentName='#form.dept#'
order by "#form.hidetxt#"
</cfif>
<cfif ListLen(Form.salary,'-') EQ 2>
AND TE.salary between #ListGetAt(Form.salary,1,'-')# AND #ListGetAt(Form.salary,2,'-')#
order by "#form.hidetxt#"
</cfif>
</cfquery>
<!--- <cfquery name="result" datasource="Training">
select TE.firstname,TE.lastname,TD.deparmentname,TE.salary,TE.DateOfBirth
from TEmployee as TE,Tdepartment as TD
where TE.departmentID=TD.departmentID
<cfif #len(form.fname)# gt 0 and #len(form.lname)# gt 0>
and TE.firstname=<cfqueryparam value="#Form.fname#" CFSQLType="CF_SQL_VARCHAR"> and TE.lastname=<cfqueryparam value="#Form.lname#" CFSQLType="CF_SQL_VARCHAR">
</cfif>
</cfquery> --->
</cfoutput>
}
</script>
我的 html
<body onload="loadval()" >
<form method="post" id="form2">
<input type="hidden" name="hidetxt" value="" id="hidetxt">
<table border="1">
<tr>
<td onclick="fnsort('firstname')">
<b>Firstname</b>
</td>
<td>
<b>Lastname</b>
</td>
<td>
<b> Departname</b>
</td>
<td>
<b> Salary</b>
</td>
<td>
<b> Dob</b>
</td>
</tr>
<cfoutput query="result">
<tr>
<td>
<b>#result.firstname# </b>
</td>
<td>
<b>#result.lastname#</b>
</td>
<td>
<b>#result.deparmentname# </b>
</td>
<td>
<b>#result.salary# </b>
</td>
<td>
<b>#result.DateOfBirth#</b>
</td>
</tr>
</cfoutput>
</table>
<!--- <input type="text" name="txtfname" id="txtfname"> --->
</form>
</body>
错误:在 FORM 中未定义元素 HIDETXT。请告诉我如何纠正这个
单击 firstname 单元格时,我需要对 firstname 进行排序。我收到此错误,如何获取“form.hidetxt”值。此页面名称为“display_report.cfm”