Classic ASP and 'AJAX', and a database update
-
I have an old classic ASP app that I am trying to do some AJAX on (the real way, not Microsoft .Net way). I have a couple of DIVs that are alternated from hidden to visible (depending on if its an UPDATE or READ), which are controlled by a href='#' and an ONCLICK call to some javascript to do the hiding/displaying. My question is, whats the best approach to trigger a database update back when the hyperlink is clicked for the update? Should I be changing the hyperlink to a form button, or have a full form hidden and displayed, rather than just a hyperlink? Just looking for an approach, dont need actual code. Here is a brief sample of the code I am working with. Note its in a Do..Until loop and returns a few hundred entries back from the database. showHide simply swaps the display: setting, and changeHTML changes the innerHTML of the control passed to it.
<script type="text/javascript">
function showHide<% Response.Write unqID %>()
{
unqID = '<%Response.write unqID %>';
showHide('Comment' + unqID);
showHide('ExpandComment' + unqID);
if(document.getElementById('Edit' + unqID).innerHTML == 'Update')
{changeHTML('Edit' + unqID,'Edit...');}
else
{changeHTML('Edit' + unqID,'Update');}}
</script>
<a href="#" id="Edit<%Response.write curATMID %>" onclick="showHide<%Response.write unqID %>(); return(false);" class="Comment">Edit...</a>
<div id="<%Response.write "Comment" & unqID %>">
<% Response.Write "<b>" & Trim(db("Comments")) & "</b>" %>
</div><div id="Expand<%Response.write "Comment" & curATMID %>" style="display:none">
<textarea id='cmtUpdate<%Response.write "Comment" & curATMID %>' type='text'
style='width:100%; height=60px;'
rows='4' cols='100'>
<%Response.Write Trim(db("Comments")) %> </textarea>
</div>