Okay, I don’t think you’re really clear on the concept of which code runs server-side, and which code runs on the client. Javascript is client side code. Your VB code runs on the server. What you’re going to do is use your asp to generate that Javascript. Then when the resultant page is loaded on the client, the Javascript will be executed. For example, you could have something like this:
<script language="Javascript">
function sendData()
{
var mydata="<%=myServerVariable%>";
window.parent.getData(myData);
}
</script>
Now, that ASP code snippet will be replaced on the server with whatever is in myServerVariable. For example, let’'s say that myServerVariable was the result of an SQL query, which returned the name ‘Fred’. If you looked at the code above in your browser after it returned from the server, this is what you’d actually see:
<script language="Javascript">
function sendData()
{
var mydata="fred";
window.parent.getData(myData);
}
</script>
Again, this is just one way to do it, but it will work. You could generate entire javascript arrays on the server side if you wanted. For instance, let’s say your SQL query returned an array of strings (“Foo”,“bar”,“snafu”). You could write something like this:
Response.write("var myArray = new Array();");
for i = 0 to myArray.length-1
Response.write("myArray(" & i & ") = '" & myArray* & "';")
next
The resulting Javascript that would be generated would look like this:
var myArray = new Array();
myArray(0) = 'foo';
myArray(1) = 'bar';
myArray(2) = 'snafu':
Now you can write your javascript function to pass the array to the calling page.
Does that make sense?
Note that this is plain-jane ASP type stuff. ASPX, depending on the features you use, can be quite different. But the concept is the same - keep in mind that your vb code runs on the SERVER, and Javascript runs on the CLIENT. If you want to send data back to a client and execute it in Javascript, you have to convert the results of your server-side query to client-side code. There are many, many ways to do this. For example, instead of dynamically creating that Javascript array, I could have just dumped the contents of the array into a hidden DIV on the page as comma-delimited text, then parsed it when it loads back in the client. You could even dynamically generate XML and use an XML data island object if you’re using IE only.