reload html table data after database entry deleted

前端 未结 1 532
暗喜
暗喜 2021-01-29 05:55

I am building a web page using asp classic and populating a mdb into an html with delete button at the end of each row. When the delete button is clicked the database entry is b

相关标签:
1条回答
  • 2021-01-29 06:34

    Probably the easiest way would be to give each <tr> an id based on the id of the current record then use JavaScript to post to the delete routine (which will be held in a separate ASP file), then hide the row by changing the style.display.

    <tr id="row<%= rs("recordId") %>>
        <td>...</td>
        <td>...</td>
        <td>
            <input type="button" value="Delete" OnClick="deleteRow(<%= rs("recordId") %>);"
        </td>
    </tr>
    

    And the JavaScript could be something like...

    var xmlhttp;
    if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();    // code for IE7+, Firefox, Chrome, Opera, Safari...
    else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");      // code for IE6, IE5
    
    function ajaxPage(postPage, paramList) {xmlhttp.open("POST",postPage,false);xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttp.send(paramList);return xmlhttp.responseText;}
    
    function deleteRow(id) {
        ajaxPage("deleteFunctionPage.asp", "id=" + id);
        document.getElementById("row" + id).style.display = "none";
    }
    
    0 讨论(0)
提交回复
热议问题