PDA

View Full Version : DHTML Billboard (HELP)



Mustapha
03-14-2009, 07:30 PM
Hi,

Im trying to read the content of the billbord from a database but I get an error when it comes to function startbill() because Im creating the divs Dynamicly while reading the records from the database.
The function startbill() has a variable called totalDivs which in my case is totalDivs=0.

Can I pass the the number of the total divs when Im finishing reading all the records from the database?

http://www.dynamicdrive.com/dynamicindex2/dhtmlbillboard.htm

best regards

Mustapha

Nile
03-15-2009, 12:55 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.
When pasting a code, please remember to use [code] tags. That includes [ html ], [ code ], and [ php ].

Also see if any of these (http://www.dynamicdrive.com/dynamicindex2/) scripts here will help. Before I can resume helping you, please do the above (in the bordered boxes).

Mustapha
03-16-2009, 08:38 AM
Hi again,

Im adding the last letter of div ID dynamicly while itterating through the records that the first Div is called billbord0, billbord1, billbord2 etc...

My code is as follows:

<%@ Page language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta content="VBScript" name="vs_defaultClientScript"/>
<script src="jquery-1.2.6.pack.js" type="text/javascript"></script>
<style type="text/css"> /*Modify attributes of #contentwrapper below as desired*/ #contentwrapper{ width: 230px; height: 200px; border: 1px solid black; background-color: #efebef; padding: 5px; }
.billcontent{ width: 100%; display:block; }
</style>

<script type="text/javascript">

/***********************************************
* DHTML Billboard script- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//List of transitional effects to be randomly applied to billboard:
var billboardeffects=["GradientWipe(GradientSize=1.0 Duration=0.7)", "Inset", "Iris", "Pixelate(MaxSquare=5 enabled=false)", "RadialWipe", "RandomBars", "Slide(slideStyle='push')", "Spiral", "Stretch", "Strips", "Wheel", "ZigZag"]

//var billboardeffects=["Iris"] //Uncomment this line and input one of the effects above (ie: "Iris") for single effect.

var tickspeed=5000 //ticker speed in miliseconds (2000=2 seconds)
var effectduration=1000 //Transitional effect duration in miliseconds
var hidecontent_from_legacy=1 //Should content be hidden in legacy browsers- IE4/NS4 (0=no, 1=yes).

var filterid=Math.floor(Math.random()*billboardeffects.length)

document.write('<style type="text/css">\n')
if (document.getElementById)
document.write('.billcontent{display:none;\n'+'filter:progid:DXImageTransform.Microsoft.'+billboardeffects[filterid]+'}\n')
else if (hidecontent_from_legacy)
document.write('#contentwrapper{display:none;}')
document.write('</style>\n')

var selectedDiv=0
var totalDivs=0

function contractboard(){
var inc=0
while (document.getElementById("billboard"+inc)){
document.getElementById("billboard"+inc).style.display="none"
inc++
}
}

function expandboard(){
var selectedDivObj=document.getElementById("billboard"+selectedDiv)
contractboard()
if (selectedDivObj.filters){
if (billboardeffects.length>1){
filterid=Math.floor(Math.random()*billboardeffects.length)
selectedDivObj.style.filter="progid:DXImageTransform.Microsoft."+billboardeffects[filterid]
}
selectedDivObj.filters[0].duration=effectduration/1000
selectedDivObj.filters[0].Apply()
}
selectedDivObj.style.display="block"
if (selectedDivObj.filters)
selectedDivObj.filters[0].Play()
selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
setTimeout("expandboard()",tickspeed)
}

function startbill(){
while (document.getElementById("billboard"+totalDivs)!=null)
totalDivs++
if (document.getElementById("billboard0").filters)
tickspeed+=effectduration
expandboard()
}

if (window.addEventListener)
window.addEventListener("load", startbill, false)
else if (window.attachEvent)
window.attachEvent("onload", startbill)
else if (document.getElementById)
window.onload=startbill

</script>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"/>
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"/>

</head>
<body>
<%

Dim conn As New SqlConnection()
conn.ConnectionString = "Data Source=global;Initial Catalog=globalintranet;Persist Security Info=True;User ID=sa;Password=test;Connection TimeOut=60;"
Dim theSQLCommand As New SqlCommand("SELECT NewsHeadline, NewsContent, Link, Author, Company FROM News")
theSQLCommand.Connection = conn
theSQLCommand.Connection.Open()
Dim theSqlDataReader As SqlDataReader = theSQLCommand.ExecuteReader(CommandBehavior.CloseConnection)
Dim x As Integer
Dim z As Integer

x = 0

If theSqlDataReader.HasRows = True Then
z = theSqlDataReader.RecordsAffected.ToString
Try
Response.Write("<div id=contentwrapper>")
While theSqlDataReader.Read()
Response.Write(theSqlDataReader("<div class=billcontent id=billboard" & x & ">" & theSqlDataReader("NewsHeadline").ToString()))
'Response.Write(theSqlDataReader("NewsHeadline").ToString() & "<br><a href=http://" & theSqlDataReader("link").ToString() & " target=" & Chr(34) & "_blank" & Chr(34) & ">ls mer</a>")
Response.Write(theSqlDataReader("NewsContent").ToString())
Response.Write("</div>")
x = x + 1

End While
Response.Write("</div>")

theSQLCommand.Connection.Close()
Response.Write(x.ToString())

Catch F As Exception
'Console.WriteLine("The file could not be read:")
Console.WriteLine(F.Message)

End Try
End If

%>
</body>
</html>

Nile
03-17-2009, 01:31 AM
Sorry, I thought you were using PHP. I have no skills in ASP whatsoever... :(