vbscript/asp Script interaction

Results 1 to 2 of 2

Thread: vbscript/asp Script interaction

  1. #1
    Join Date
    Dec 1969

    Default vbscript/asp Script interaction

    anyone know how to pass an array initialized in server script back to a client script function? I have tried everything, but the vbscript function i made keeps giving me errors

  2. #2
    Join Date
    Dec 1969

    Default Read this first...

    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=169<BR><BR>And then consider: *WHAT* can ASP send to the browser? (Ignoring the case where you send binary data, say, by changing the encoding and mime types.)<BR><BR>Answer: text. Period. HTML. Only.<BR><BR>Now, that HTML *can* include scripting code (more commonly JavaScript, since VBS won&#039;t run in non-MSIE browsers, but still...).<BR><BR>In other words you can do things like:<BR><BR>Response.Write "&#060;SCRIPT Language=VBScript&#062;document.write(""&#060;H2&# 062;Heading&#060;/H2&#062;"")&#060;/script&#062;"<BR><BR>(Kind of silly to do that, but the point is you can.)<BR><BR>So... Let&#039;s review:<BR><BR>How do you send *ANYTHING* from ASP to the browser?<BR>By sending HTML text.<BR><BR>And your question:<BR><BR>How do you send a server-side VBS array to the browser, to be used by browser-side VBS?<BR><BR>See the prior question.<BR><BR>So here&#039;s one example:<BR><BR>&#060;%<BR>aspArray = Array( "This","array","was","created","on","the","Server. ")<BR><BR>Response.Write "browserArray = Array("<BR>For i = 0 To UBound(aspArray)<BR>&nbsp; &nbsp; Response.Write """" & aspArray(i) & """"<BR>&nbsp; &nbsp; If i &#060;&#062; UBound(aspArray) Then Response.Write ","<BR>Next<BR>Response.Write ")" & vbNewLine<BR>%&#062;<BR><BR>Now, that works, but it is pretty darned clumsy, yes?<BR><BR>So what do we have in VBS that helps us convert an array to a Response.Write-able string? Yep...the Join function.<BR><BR>**************<BR>&#060;%<BR>aspA rray = Array( "This","array","was","created","on","the","Server. ")<BR>%&#062;<BR>&#060;SCRIPT Language=VBScript&#062;<BR>browserArray = Array( "&#060;% = Join(aspArray,""",""") %&#062;" )<BR>&#060;/SCRIPT&#062;<BR><BR>*************<BR><BR>Okay?<BR> <BR>Naturally, if you are sending an array of numbers you don&#039;t need all those hokey "" marks that end up being a single " in the resultant HTML.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts