0

I've got page "summary.asp" which runs an sql query to fill an html table with data. When I try to add some jquery to the page so I can export the html table as an excel file, it simply fails. The button that calls the function isn't responsive in IE, Chrome, or Firefox. Any guidance would be appreciated.

    <html>
    <head>
    <link rel="stylesheet" href="default.css">
    <link rel="stylesheet" href="header.css">
    <script type="text/javascript" src="//code.jquery.com/jquery-1.8.3.js"></script>


<!--This is the script that should be working the export magic-->
<script type='text/javascript'>//<![CDATA[
$(function(){
$("#btnExport").click(function (e) {
    window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
    e.preventDefault();
});
});//]]> 


</script>
</head>
<body>

<input type="button" id="btnExport" value=" Export Table data into Excel " />
</br>
</br>

<%
dim startdate
    startdate = request.form("datepickstart")
    dim enddate
    enddate = request.form("datepickend")
%>

    <strong>
    Summary of Support:
    <% =startdate %>
        to:
    <% =enddate %>
    </strong>

<p>Click on individual links for more details of execution.</p>
<%
    dim dbconn
    set dbconn = server.createobject("adodb.connection")
    dbconn.open "dsn=*****;uid=*****;pwd=*****"

    'if dbconn.errors.count > 0 then
    '   response.write "connection erros<br>"
    '   for each objerr in dbconn.errors
    '       response.write objerr.source & "<br>"
    '       response.write objerr.description & "<br>"
    '   next
    'end if

    dim supportrecordset
    dim sqlstr
    sqlstr = SQL statement
    set supportrecordset = server.createobject("adodb.recordset")
    supportrecordset.open sqlstr, dbconn
%>

<div id="dvData">
<table align=center border=2 width=60%>
    <tr>
        <th>Summary</th>
        <th>Start Time</th>
        <th>End Time</th>
        <th>Result</th>
    </tr>
<%
    while not supportrecordset.eof
        response.write "<tr><td align=center>"
        response.write supportrecordset("si_host") &  "</td><td align=center>"
        response.write "<a href=epdetails.asp?epsummid=" 
        response.write supportrecordset("si_id")
        'make the link red if the status is not success
        if supportrecordset("si_status_id") = 1 then
            response.write "><font color=blue><strong>"
        else
            response.write "><font color=red><strong>"
        end if
        response.write trim(supportrecordset("si_start_ts")) & "<strong></font></a></td><td align=center>"
        response.write trim(supportrecordset("si_end_ts")) & "</td><td align=center>"
        response.write trim(supportrecordset("st_status_description")) & "</td>"
        supportrecordset.movenext
    wend
    supportrecordset.close
    dbconn.close
%>
</table>
</div>

</body>
</html>
  • *it simply fails*...In what way? *"This fails, why?"* isn't a very good question. Please read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) – Liam Jun 17 '16 at 14:10
  • My apology. I guess the question is rather vague. When I have a HTML table in a page (example: test.HTM) the export button works just fine, but in every .ASP page, this script fails. Is there a jquery/.ASP conflict? – jwabsolution1 Jun 17 '16 at 14:16
  • asp and jquery are totally independant technologies. So that doesn't make sense. Is there an [error in the console](http://stackoverflow.com/questions/988363/how-can-i-debug-my-javascript-code)? – Liam Jun 17 '16 at 14:28
  • I took out the scripts that aren't running on this page. I made the edits above. Now... I download the file in Chrome and FireFox, but for some odd reason IE opens a new tab and doesn't export the table data. Now I'm even more confused. – jwabsolution1 Jun 17 '16 at 15:01

0 Answers0