Onclick of <a href> will execute sql statement

Good day to all! Here is the scene… I have a link in my web page:

<%

dim inv,mypic,xpic

xpic = “<a class=pic_thumbnail href='./?q=negoiteminfo&inv_id=” & rs(“InventoryNum”) & “'> Test Link </a>”

%>

I was just wondering if it is possible that if I click that link, it will execute a javascript or ajax that will retrieve the value of the variable inv_id and then use it for sql select statement.

Here’s what i have in my mind, but i just don’t know how to put it in code using javascript or ajax:

<script type=“text/javascript”>

//Declare a variable that will get the data from inv_id

var abc = inv_id

//Then execute sql statement
set inv=conn.execute(“SELECT Field1,Field2,Field3 FROM TableName WHERE FieldID='” & abc & “'”)

mypic=inv(“Field1”)

</script>

I just don’t what is the proper syntax for that javascript logic… Please help… thanks in advance! :smiley: