not sure what you mean by "a function that has an input and output" your question is sort of vague.. hard to tell what you're asking about.
maybe you want the javascript to make an async call to your asp script?
you basically write three pieces of code. 1. javascript function that gets the data from your page and makes an ajax call to asp...
2. asp page that handles the javascript call
3. a callback function ( #1 includes reference to this piece) that handles the response from piece #2 and updates your page accordingly
here's an example google turned up: http://www.15seconds.com/issue/050526.htm