navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Passing a VBscript array to java Array

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Passing a VBscript array to java Array
Page: [1]
 
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.

(in reply to lyners)
lyners

 

Posts: 93
Joined: 7/25/2003
Status: offline

 
RE: Passing a VBscript array to java Array - 8/26/2003 17:08:23   
In short. Awesome :) I've used that type of coding when doing Zebra II language, but I didn't think about it here. I have everything working, but I need an extra set of eyes. I am getting a "Subscript out of range: 'Picture'" when running this.

My ubound returns 3, which is what it is suppose to do. Do you see a problem with my for loop?

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 Files"
' 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"
else
	' grab records
	picture=rstemp.getrows
end if

Call Cleanup

SUB Cleanup
   rstemp.close
   set rstemp=nothing
   conntemp.close
   set conntemp=nothing
END SUB

' =========================
' End of get Data
' =========================

'==========================
'Create javascript through vb
'==========================

response.write "<p>" & ubound(picture,2) & "</p>"
response.write("<script>" & vbcrlf)
response.write("var SlideShowSpeed = 3000;" & vbcrlf)
response.write("var CrossFadeDuration = 3;" & vbcrlf)
response.write("var Picture = new Array();" & vbcrlf)
for i = 1 to ubound(picture,2)
	response.write("Picture[" & i &"]  = '" & picture(i) & "'" & vbcrlf)	
next
response.write("var tss;" & vbcrlf)
response.write("var iss;" & vbcrlf)
response.write("var jss = 0;" & vbcrlf)
response.write("var pss = Picture.length-1;" & vbcrlf)
response.write("var preLoad = new Array();" & vbcrlf)
response.write("var preLoad = new Array();" & vbcrlf)
response.write("for (iss = 0; iss < pss+1; iss++){" & vbcrlf)
response.write("preLoad[iss] = new Image();" & vbcrlf)
response.write("function runSlideShow(){" & vbcrlf)
response.write("if (document.all){" & vbcrlf)
response.write("document.images.PictureBox.style.filter='blendTrans(duration=2)';" & vbcrlf)
response.write("document.images.PictureBox.style.filter='blendTrans(duration=CrossFadeDuration)';" & vbcrlf)
response.write("document.images.PictureBox.filters.blendTrans.Apply();}" & vbcrlf)
response.write("document.images.PictureBox.src = preLoad[jss].src;" & vbcrlf)
response.write("if (document.all) document.images.PictureBox.filters.blendTrans.Play();" & vbcrlf)
response.write("jss = jss + 1;" & vbcrlf)
response.write("if (jss > (pss)) jss=1;" & vbcrlf)
response.write("tss = setTimeout('runSlideShow()', SlideShowSpeed);" & vbcrlf)
response.write("}" & vbcrlf)
response.write("</script>" & vbcrlf)
%>



And to make sure this is legal, the java code for the picture rotate came from Codelifter.com :)

Thanks!

(in reply to lyners)
Spooky

 

Posts: 26597
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Passing a VBscript array to java Array - 8/27/2003 0:42:37   
Any reason you are using "for i = 1 to ubound(picture,2)" for a 0 based array?
Id assume for i = 0 to ubound(picture,2)

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to lyners)
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.

(in reply to lyners)
lyners

 

Posts: 93
Joined: 7/25/2003
Status: offline

 
RE: Passing a VBscript array to java Array - 8/27/2003 12:00:47   
Figured it out.

When using getrows, the array that is retrieved must be accessed by using array(column,row). You cannot just say array(row), which I was trying. So my answer for the above problem was;

picture(0,i)

And the rest is history. :)

Thanks for all the help!

(in reply to lyners)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Passing a VBscript array to java Array
Page: [1]
Jump to: 1





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