[thelist] Calling a function in ASP from a link

Richard Bennett richard.bennett at skynet.be
Sun Dec 9 15:28:10 CST 2001


hi,
Ok, you want to call a function on the server, from the client, without
reloading the page, or using a frameset.
This is one way:

<script>
    var Sender=new Image()
    var custID='100 bookmark this'

    function updateDatabase(){

Sender.src='http://www.server.com/cgi-bin/script.asp?custID='+escape(custID)
        return false
    }
</script>

and then:
< a href="javascript:#" onclick="return updateDatabase()">Bookmark this
record</a>

That should do it.
Taken one step further, the server-script can redirect to an image, if the
update was performed successfully, or to an .html page if not.
Then your image will trigger an onload event for success, and an onerror
event for an error.
you would listen for that like this:

Sender.onerror=function(){alert("something went wrong")}
Sender.onload=function(){alert("All OK")}


Cheers,
Richard.


----- Original Message -----
From: "Michael Galvin" <mpgalvin at eircom.net>

> I have an ASP page and on it, I want to give the user the opportunity to
> "bookmark" a certain record in the database (ie. the one they're currently
> on).  I have the function written, etc, but have no idea how to get it to
> work from a link.






More information about the thelist mailing list