Click to See Complete Forum and Search --> : Random Images


WandaLL
12-08-2003, 02:18 PM
:confused:

I am using the following script in an includes file but when I try to run the file that the include is in, I get an error message that says "Expected end of statement
/sdu/PluggedIn_new/includes/rotating_faces.inc, line 16, column 9". Any ideas as to why this is happening? --Thanks...


<script language="JavaScript1.1">
<!--

/*Browsercheck:*/
if(document.all){
var ie=document.all?1:0;
//var n=0
}else{
var n=document.layers?1:0;
}

<%

'create file path to database

Dim path As String = Server.MapPath(Session("SDUVirtualBasePath")) & "/about_sdu/whos_who/database.txt"

'open the file
Dim sduAssociates As StreamReader
sduAssociates = File.OpenText(path)

'initialize counter

Dim counter As Integer = 0

'search through database
Dim name As String
Dim bio As String
Dim title As String
Dim alpha As String
Dim group As String
Dim splitName As String
Dim splitName2 As String

While sduAssociates.Peek() <> -1

name = sduAssociates.ReadLine()
bio = sduAssociates.ReadLine()
title = sduAssociates.ReadLine()
alpha = sduAssociates.ReadLine()
group = sduAssociates.ReadLine()
sduAssociates.ReadLine()

counter = counter + 1

'Create the link array

if instr(name, "'") then
splitName = Left(name, instr(name, "'") - 1)
splitName2 = Right(name, len(name) - instr(name, "'"))
name = splitName & splitName2
end if

response.write("var image" & counter & "=new Image()" & chr(10))
response.write("image" & counter & ".src=""" & Session("SDUSiteBase") & "/images/about_sdu/associates/" & name & ".jpg""" & chr(10) & chr(10))

End While

' close and clean up

sduAssociates.Close()
%>
//-->
</script>
<script language="JavaScript1.2">
function reapply(){
setTimeout("slideit()",3000)
return true
}
window.onerror=reapply
</script>
<base target="_self">
<script>
<!--

//change speed below (in seconds)
var speed=3
var random
var destHREF
Link=new Array()
AssociateName=new Array()
<%
'create file path to database

path = Server.MapPath(Session("SDUVirtualBasePath")) & "/about_sdu/whos_who/database.txt"

'open the file
sduAssociates = File.OpenText(path)

'initialize counter

counter = 0

'search through database

While sduAssociates.Peek() <> -1

name = sduAssociates.ReadLine()
bio = sduAssociates.ReadLine()
title = sduAssociates.ReadLine()
alpha = sduAssociates.ReadLine()
group = sduAssociates.ReadLine()
sduAssociates.ReadLine()

'Create the link array

if instr(name, "'") then
splitName = Left(name, instr(name, "'") - 1)
splitName2 = Right(name, len(name) - instr(name, "'"))
name = splitName & splitName2
end if

response.write("Link[" & counter & "]=""" & Session("SDUSiteBase") & "/about_sdu/whos_who/pop_up_associate.asp?id=" & name & """" & chr(10))
response.write("AssociateName[" & counter & "]=""" & name & """" & chr(10) & chr(10))

counter = counter + 1

End While

' close and clean up

sduAssociates.Close()
%>

function initIt(){
sdu_Name.style.filter = "blendTrans(duration=3)"
slideit();
}

function slideit(){
//alert("ok")
random=Math.round(Math.random()*<%=counter - 1%>)
destHREF=Link[random-1]
if (!document.images)
return
if (document.all)
sdu_Name.filters.blendTrans.Apply();
slide.filters.blendTrans.Apply();
sdu_Name.innerHTML = AssociateName[random-1];
document.images.slide.src = eval("image"+random+".src");
slide.filters.blendTrans.Play();
sdu_Name.filters.blendTrans.Play();
if (document.all)
setTimeout("slideit()",speed*1000+3000)
else
setTimeout("slideit()",speed*1000)
}

//-->
</script>

David Harrison
12-08-2003, 04:45 PM
Erm... from here:

<%

'create file path to database

Dim path As String = Server.MapPath(...

onwards is ASP. That's a server-side language and so it needs to be run on the server and the server must have ASP enabled. Could this be why?

WandaLL
12-08-2003, 05:03 PM
The server is ASP enabled and 95% of what we do is asp.

Also, when this is used in an aspx file, it works perfectly.

David Harrison
12-08-2003, 05:10 PM
So why did you post the ASP then? Can you just post the source for the page you get, including the HTML and everything. Otherwise, how do I know which is line 8?

WandaLL
12-08-2003, 05:35 PM
This is where it is breaking:

Dim path As String = Server.MapPath(Session("VirtualBasePath")) & "/about_sdu/whos_who/database.txt"

fredmv
12-08-2003, 05:38 PM
If you were aware of that, then why did you ask in the JavaScript section? That is clearly a piece of ASP/VBScript code. Therefore, you should be asking in the ASP forum.