Click to See Complete Forum and Search --> : ASP Loop in a Java Script?


mbarbu
04-02-2003, 12:20 PM
OK, I'm only going to post a little slice of a script that I'm using. I want to be able to have the marked section pulled from a dB using ASP/VB/SQL:

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
//slider's width
var swidth=350

//slider's height
var sheight=72

//slider's speed
var sspeed=2

//messages: change to your own; use as many as you'd like; set up Hyperlinks to URLs as you normally do: <a target=... href="... URL ...">..message..</a>
var singletext=new Array()
:confused: ----------START DB LOOP---------- :confused:
singletext[0]='Line 0'
singletext[1]='Line 1'
singletext[2]='Line 2'
singletext[3]='Line 3'
:confused: ------------END DB LOOP----------- :confused:
if (singletext.length>1)
i=1
else
i=0
function start(){
if (document.all){
ieslider1.style.top=sheight
iemarquee(ieslider1)
}
else if (document.layers){
document.ns4slider.document.ns4slider1.top=sheight
document.ns4slider.document.ns4slider1.visibility='show'
ns4marquee(document.ns4slider.document.ns4slider1)
}
else if (document.getElementById&&!document.all){
document.getElementById('ns6slider1').style.top=sheight
ns6marquee(document.getElementById('ns6slider1'))
}
}

mbarbu
04-02-2003, 02:27 PM
Can anyone help me? I'm not a huge JavaScript person and I really want to make this work :(

mbarbu
04-03-2003, 08:52 AM
Stupid me. It was easier then I thought. You can drop ASP code right into JavaScript. My solution is below:

<%
Counter = 0
Do while not DataCommand1.eof
Counter = Counter + 1
%>
singletext[<%= Counter %>]='<a href="/article-details.asp?k=<%= DataCommand1("keyID") %>" class="8-b" target="_parent"><%= DataCommand1("varTitle") %></a>'
<%
DataCommand1.movenext
LOOP
%>

jrthor2
04-08-2003, 11:56 AM
thans so much for this code, it has really helped me out. Just one question, how do you get the array to start at 0? It starts at 1 the wya it is coded now?

jrthor2
04-08-2003, 11:57 AM
nevermind, i just ste the counter = -1 and that worked.

mbarbu
04-08-2003, 12:25 PM
I had the '0' array static. I had a title listed in it. :D