|
| |
|
|
lyners
Posts: 93 Joined: 7/25/2003 Status: offline
|
Passing a VBscript array to java Array - 8/26/2003 14:01:11
I am trying to pass an array I created in VBscript to an array in java script. What I have done is created code that accesses a table. I take the data from the table and put it in an array. Now I need to use javascript to do what I need to do, but I must use the array I created in the vbscript. I do not know how to do this, or I am having a very difficult time trying to figure it out. here Is the code
<%
' =============================
' Get Data from Table
' =============================
' Set variables
DIM myDSN, mySQL, conntemp, rstemp, aMonthValues
' The next lines are for Access DBs - rename the DB name to match yours
' Use this next one for Access 97
' myDSN=" DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("/fpdb/myDatabase.mdb" )
' Uncomment the next one for Access 2K / XP
myDSN =" Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../capfin/fpdb/capital.mdb" )
' Put your SQL next
mySQL="SELECT 'Project_Images/'+[FileName] AS Expr1 FROM Project_Info " & _
"INNER JOIN Files ON (Project_Info.Phase = Files.Phase) AND " & _
"(Project_Info.Sub_Project = Files.Sub_Project) AND " & _
"(Project_Info.Project = Files.Project)"
' Build & connect
set conntemp=Server.CreateObject("ADODB.Connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
If rstemp.eof then
picture(0) = "project_Images/blank.jpg"
end if
' grab records
picture=rstemp.getrows
Call Cleanup
SUB Cleanup
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
END SUB
for i = 0 to ubound(picture,2)
response.write "<p>" & picture(i) & "</p>
next 1
' =========================
' End of get Data
' =========================
%>
<script>
// (C) 2002 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header.
// ==============================
// Set the following variables...
// ==============================
// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;
// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;
var Picture = new Array(); // don't change this
//var Caption = new Array(); // don't change this
// Specify the image files...
Picture = <%picture%>
// =====================================
// Do not edit anything below this line!
// =====================================
var tss;
var iss;
var jss = 0;
var pss = Picture.length-1;
var preLoad = new Array();
for (iss = 0; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];}
function runSlideShow(){
if (document.all){
document.images.PictureBox.style.filter="blendTrans(duration=2)";
document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
document.images.PictureBox.filters.blendTrans.Apply();}
document.images.PictureBox.src = preLoad[jss].src;
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
jss = jss + 1;
if (jss > (pss)) jss=1;
tss = setTimeout('runSlideShow()', SlideShowSpeed);
}
</script>
What do I need to do to use the array I created in the vbscript to use it in the Java? Thanks ahead of time!
|
|
|
|
rdouglass
Posts: 9167 From: Biddeford, ME USA Status: offline
|
RE: Passing a VBscript array to java Array - 8/26/2003 15:59:12
The basic rule of thumb that I use is that JavaScript runs at the client and VBScript in ASP runs at the server. So what I try to do is to make VBScript response.write the JavaScript code. Here is an example of one I use. Again, I don't actually pass the VBScript array to the JavaScript, I use the VBScript array to write out the JavaScript. **************************** <% Response.write("<script>" & vbcrlf) Response.write("<!--" & vbcrlf) Response.write("var content=new Array()" & vbcrlf) Response.write("content[0]='<font face=" & CHR(034) & "Verdana" & CHR(034) & " size=" & CHR(034) & "2" & CHR(034) & "><b>Our New Look!</b></font><br><br><font face=" & CHR(034) & "Verdana" & CHR(034) & " size=" & CHR(034) & "1" & CHR(034) & ">This area is used to display the next 3 events for the user being selected.<br><br>Hold the cursor over a name to see the next 3 events.</font>'" & vbcrlf) 'next line is an external function buildUserArray(1) numrows=ubound(alldata,2) myIDList = "" FOR rowcounter= 0 TO (numrows) myIDList = myIDList & alldata(3,rowcounter) & "," NEXT myIDList = left(myIDList,(len(myIDList)-1)) set conntempIDList=server.createobject("adodb.connection") conntempIDList.open myDSN mySQLIDList = ("SELECT * FROM tblItems WHERE (UserOut = true) ORDER BY ItemStart ASC") set rstempIDList=conntempIDList.execute(mySQLIDList) IF rstempIDList.eof THEN Response.write("No IDs in list!") rstempIDList.close set rstempIDList=nothing conntempIDList.close set conntempIDList=nothing ELSE ' Now lets grab all the records alldataIDList=rstempIDList.getrows rstempIDList.close set rstempIDList=nothing conntempIDList.close set conntempIDList=nothing END IF FOR rowcounter= 0 TO (numrows) 'lastname=alldata(0,rowcounter) 'firstname=alldata(1,rowcounter) Response.write("content[" & alldata(3,rowcounter) &"]='<font face=" & CHR(034) & "Verdana" & CHR(034) & " size=" & CHR(034) & "2" & CHR(034) & "><b>" & alldata(0,rowcounter)& ", " & alldata(1,rowcounter) & "</b></font><br><br>") Response.write("<font face=" & CHR(034) & "Verdana" & CHR(034) & " size=" & CHR(034) & "1" & CHR(034) & ">" & nextThreeEvents(alldata(3,rowcounter))) Response.write("</font>'" & vbcrlf) NEXT Response.write("function regenerate(){" & vbcrlf) Response.write("window.location.reload()" & vbcrlf) Response.write("}" & vbcrlf) Response.write("function regenerate2(){" & vbcrlf) Response.write("if (document.layers){" & vbcrlf) Response.write("appear()" & vbcrlf) Response.write("setTimeout(" & CHR(034) & "window.onresize=regenerate" & CHR(034) & ",450)" & vbcrlf) Response.write("}" & vbcrlf) Response.write("}" & vbcrlf) Response.write("function changetext(whichcontent){" & vbcrlf) Response.write("if (document.all||document.getElementById){" & vbcrlf) Response.write("cross_el=document.getElementById? document.getElementById(" & CHR(034) & "descriptions" & CHR(034) & "):document.all.descriptions" & vbcrlf) Response.write("cross_el.innerHTML='<font face=" & CHR(034) & "Verdana" & CHR(034) & " size=" & CHR(034) & "1" & CHR(034) & ">'+whichcontent+'</font>'" & vbcrlf) Response.write("}" & vbcrlf) Response.write("else if (document.layers){" & vbcrlf) Response.write("document.d1.document.d2.document.write('<font face=" & CHR(034) & "Verdana" & CHR(034) & " size=" & CHR(034) & "1" & CHR(034) & ">'+whichcontent+'</font>')" & vbcrlf) Response.write("document.d1.document.d2.document.close()" & vbcrlf) Response.write("}" & vbcrlf) Response.write("}" & vbcrlf) Response.write("function appear(){" & vbcrlf) Response.write("document.d1.visibility='show'" & vbcrlf) Response.write("}" & vbcrlf) Response.write("window.onload=regenerate2" & vbcrlf) Response.write("//-->" & vbcrlf) Response.write("</script>" & vbcrlf) %> ********************** It ends up being a big excersize in loops and response.writes... Does that help any????
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
lyners
Posts: 93 Joined: 7/25/2003 Status: offline
|
RE: Passing a VBscript array to java Array - 8/27/2003 10:08:23
No, that was part of testing what was happening with my picture array. I still am getting subscript out of range error on it. I will make it 0 again, but that still won't fix my problem. I bet this is something simple that I just don't see.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|