vivalet,
What you have tried is the way to do it.
You can fill in the dynamic vaiables with <%= variableName%> or you can write the entire code in a string if it suits better.
eg
Code:
<%
response.write("<script language=javasccript>")
response.write("function alertMe()")
response.write("{alert('This is me')}")
response.write("</script")
%>
If this is not working for you try a very simple example and build on it.
I often use dynamic
js in this fashion and it can be a useful tool
Rod
======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================