正在打印Javascript而不是ASP(经典)输出

时间:2012-05-04 13:30:12

标签: javascript asp-classic

我正在尝试创建一个列出记录的页面,并允许显示一个表单来编辑值。它重新加载页面,并在末尾添加“?edit = true”,因此它知道将数据拉入表单,而不是列出所有条目。我在iframe中加载它之后做了这个,以替换身体不起作用。而且我已经设法以完全相同的方式以不同的形式执行此操作 - 除了它有效。 (实际上,我有两个显示表单的函数,只会显示1个)

我得到的输出而不是表单是

  

} catch(e){alert(e); }

这是最后加载的底部:

    <script type="text/javascript">
        try {

        document.getElementById("viewb").style.display = "none";
        document.getElementById("reviewb").style.display = "none";
        document.getElementById("editb").style.display = "none";
        document.getElementById("reeditb").style.display = "none";
        document.getElementById("delb").style.display = "none";
        document.getElementById("panel").innerHTML = "<%call showAScreen()%>";

        }catch(e) {
            alert(e);
        }
    </script>

这是第一个定义的asp函数 - 位于顶部的JavaScript函数之后:

<% sub showAScreen()

If Request.QueryString("edit") <> "" Then
    showedits()
else
    showControlScreen()
end if 
end sub %>

剩下的就是:

<% sub showedits() 'Show edit record form

        dim selsql
        selsql = ""
        selsql = selsql & "SELECT A.[NBK] as 'NBK ID'"
        selsql = selsql & " ,A.[PersonNumber] as 'Person Number'"
        ...
        selsql = selsql & " ,A.[AOIScore] as 'AOI Score'"
        selsql = selsql & " ,A.[VendorName] as 'Vendor Name'"
        selsql = selsql & "   FROM (([ReportingDevDB].[dbo].[bAssociateRoster] as A left join "
        selsql = selsql & "[ReportingDevDB].[dbo].[bAssociateRoster] as B on A.ManagerNBK = B.NBK) left join"
        selsql = selsql & "[ReportingDevDB].[dbo].[bAssociateRoster] as C on A.TeamLeadNBK = C.NBK)"
        selsql = selsql & " where A.NBK='" & Request.QueryString("edit") & "'"

        on error resume next
        set rs = cnt.execute(selsql)
        dim outstr
        outstr = "<table><tr><td id='content'>"'Frame for code to be pulled from.
        outstr = outstr & "<form id='form' method='post' action='NewRosterManager.asp?selectnbk=" & rs(0) & "&update=true'>"

            outstr = outstr & "<table class='bluetable'>"
            outstr = outstr & "<thead><tr><td colspan='32'>Edit Data</td></tr></thead>"
            outstr = outstr & "<tbody class='list' style='text-align:left'>"
            outstr = outstr & "<tr><td>NBK:</td><td id='RecordNBK'>" & rs(0) & "</td></tr>"
            ...
            outstr = outstr & "<tr><td>Vendor Name:</td><td><input type='text' id='e_VendorName' name='e_VendorName' value='" & rs(25) & "'></td></tr>"
            outstr = outstr & "</tbody></table><input type='submit'></form>"

        outstr = outstr & "</td></tr></table>"'Frame for code to be pulled from.
        Response.write "<br/>" & outstr & "<br/>"

        Response.write selsql 'this doesn't work... can't test query
end sub %>

再次......我已经尝试了过去一周我能想到的一切,在谷歌搜索中我找不到任何类似的东西。我甚至无法打印查询。

1 个答案:

答案 0 :(得分:2)

您生成的内容应该是引号,如下所示:

document.getElementById("panel").innerHTML = "<%call showAScreen()%>";

请注意&lt;%和%&gt;周围的引号标签

ASP将调用showAScreen并将其插入javascript的引号内,以便输出如下所示:

document.getElementById("panel").innerHTML = "&lt;table&gt;...&lt;/table&gt;";

更新:在showAScreen中,执行以下操作:

return "<br/>" & outstr & "<br/>"

然后

Response.write "document.getElementById('panel').innerHTML = """ & showAScreen() & """"