Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic variables(?) 1

Status
Not open for further replies.

PaulBricker

Programmer
Sep 25, 2002
3,554
US
I currently have a loop that pulls values from a table and writes them to a page.

Code:
<%WHILE NOT rst.EOF 		 
            FOR i = 0 to rst.recordcount-1		
		Response.Write rst(i) 
	    NEXT 
		rst.MoveNext
	WEND%>

But what I would like to do is store the values returned by the loop in variables. I want to use those variables in a Javascript routine that I use. This is part of the Javascript routine.
Code:
<script type="text/javascript">

/*Example message arrays for the two demo scrollers*/

var pausecontent2=new Array()
pausecontent2[0]='Dining Hall Window Replacement'
pausecontent2[1]='WB Bathroom conversion'
pausecontent2[2]='Chapel/Parking Lot Light'
pausecontent2[3]='Ath Ctr Rooftop Unit Repair'
pausecontent2[4]='Ath Ctr Wrestling Room Roof'
pausecontent2[5]='' 
</script>

Currently, I have the values for the array hard coded. What I would like is to replace those hard coded values with a variable something like this

pausecontent2[0]=<%=ASPvariable0%>

where ASPvariable0 is the first value returned by my loop.

I would like the variables to be dynamic if possible (the number of records returned can change week to week), but would be content with any solution.

Thanks very much.

Paul
 
Is your server-side logic mixed between VBScript and JavaScript or ....

or does the VBScript only run on the server and the JavaScript runs in the browser?
 
Maybe something like:
Code:
Response.Write "var pausecontent2=new Array();" & vbCrLf
iCounter = 0
Do While Not rst.EoF
  Response.Write "pausecontent2[" & iCounter & "]="
  Response.Write rst("MyField") & "';" & vbCrLf
  iCounter = iCounter + 1
  rst.MoveNext
Loop
 
The VBScript runs on the server and the JavaScript runs in the browser. I'll try your solution and post back.

Thanks

Paul
 
Thanks Sheco. That builds the array very nicely. Now, I need to figure out how to run that inside Javascript tags. I'll give it a go before I head over to the Javascript forum.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top