从sql中取出的数据varchar型,如含有单引号'或者""等字符,可以利用下面的涵数进行转换, 然后再付给JAVASCRIPT里的数组. <% function StrCheckSingle(str) if str="" or isnull(str) then exit function end if if instr(1,str,"'")>0 then str=replace(str,"'","\'") end if if instr(1,str,chr(34))>0 then str=replace(str,chr(34),"\"& chr(34)) end if StrCheckSingle=str end function %> <SCRIPT language="javascript"> <!-- var section_show = new Array(); section_show[0]="<%=StrCheckSingle(rs("category_name"))%>"; //--> </script>
然后再付给JAVASCRIPT里的数组.
<%
function StrCheckSingle(str)
if str="" or isnull(str) then
exit function
end if
if instr(1,str,"'")>0 then
str=replace(str,"'","\'")
end if
if instr(1,str,chr(34))>0 then
str=replace(str,chr(34),"\"& chr(34))
end if
StrCheckSingle=str
end function
%>
<SCRIPT language="javascript">
<!--
var section_show = new Array();
section_show[0]="<%=StrCheckSingle(rs("category_name"))%>";
//-->
</script>
现在想在<textarea>中显示数组,但库中原先的数据如:
2
3
4
现在显示成
234
有何办法恢复显示?谢谢