2

I'm trying to make a page that lists records, and allows to show a form to edit a value. It reloads the page with "?edit=true" added to the end so it knows to pull the data into a form, rather than list all entries. I did this after loading it in an iframe to replace the body wasn't working. And I have managed to do this in a different form exactly the same way - except it worked. (Actually, I have two functions that show a form, and only 1 will show up)

The output I get instead of the form is

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

This is at the bottom to be loaded last:

    <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>

This is the first defined asp function - placed after the JavaScript functions at the top:

<% sub showAScreen()

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

This is the rest:

<% 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 %>

Again... I have tried everything I can think of over the past week, and I cannot find anything remotely like this in my google searches. I cannot even get the query to print.

4

1 に答える 1

2

生成されたものは、次のように引用符で囲む必要があります。

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

<% および %> タグを囲む引用符に注意してください。

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() & """"
于 2012-05-04T13:33:38.580 に答える