Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP Text Scroller

    I have received many great tips from this site, so I thought I might share this one. It may be simple to experienced programmers, but it sure help me.

    I was looking a vertical text scroller on the web and there were many. Most were DTHML/Javascript/Applets. I tinkered around and came up with this as a very effective and neat script to put in a table cell well you want to list values out of an SQL database.

    I wanted to list Members / Usernames from an MS Access 2000 DB scrolling vertrical. This does the trick just fine and very efficiently. All variables can be defined etc. to your liking.

    Of course, ways to improve it are more than welcome!

    Code:
    <%
    '==================================================================================
    'Open Database And Get Names
    Response.write("<Marquee align='center' width='100' height='20' onmouseover='this.stop();' onmouseout='this.start();' direction='up' scrollamount='1' scrolldelay='60' top='0' left='15' style='font-family: Arial Narrow; font-size: 8pt'>" )
    			Set conn = server.createobject("adodb.connection")
    			dbName="MyDatabase.mdb"
    			connect ="provider=microsoft.jet.oledb.4.0;data source="
    			connect=connect & server.mappath(dbName)& ";"
    			conn.open connect
    			SQLstmt = "SELECT * FROM [Member]"
    			set rs = conn.Execute(SQLstmt)
    			if not rs.EOF then
    				rs.movefirst
    				Do
    					UserName = UCase(rs("UserName"))				
    					UserName = UserName & "<br>"
    					Response.write(UserName)					
    				rs.movenext
    				loop until rs.EOF	
    			End If	
    '==================================================================================
    'Clean Up And Close Database
    			Set rs = Nothing
    			Set connect = Nothing
    			Set SQLstmt = Nothing
    			conn.close
    			Set conn = Nothing
    			Set dbName = Nothing		
    Response.write( "</Marquee>" )
    '==================================================================================
    %>

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great, I was just trying to combine javascript with ASP to implement a scroll text. This code helped a lot, I will try to modify it such as giving links and trying different colours for news topic and another colour for the content, hopw it works

    Thanks again great help

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is not cross-browser, however... if you're looking for a cross-browser implementation, I would avoid the <marquee> tag.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is it only the marquee tag that avoids it from being cross browser then?

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The marquee tag is a VERY VERY bad thing.

    The reason I say that, is <marquee> is a proprietary tag introduced by Microsoft, that only works in their browsers. I'm not even sure it still works in their newest browsers.

    I would have to check to verify that, but to be honest with you, I see something like that as a waste of my time, since I personally avoid proprietary code as much as possible and try to stick to ECMA and W3 standards.

    You're much better off using another method to do whatever it is you're attempting, but I'm sure if you post your question in the "General Web building" forum in its own thread, you might get better answers, since this doesn't have much to do with ASP.

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah I have just read about marquee
    umm I better carry on what I was doing then cos as everyone does, I would like to have a cross-browser site.

    Thanx 4 warning

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You bet.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yep, This is what I was afraid of after I posted this. But Man, this little script works nice for what I have. Unfortunately, It will probably blow Netscape and all those type browsers out of the water.

    The reason I like it, and the reason I use ASP is to obviously build the text string for all the members.

    Oh well, another lesson learned here, and I hope I didn't cause any problems.

    Thx for the insight, Whammy...

    JoeP

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On the contrary... if you find out this works in other browsers, please let us know! I doubt that though. You definitely didn't cause any problems... all posts and ideas are welcomed here, and I am most definitely not correct all of the time. I learn a lot from this forum!

    However, stuff like this is just "flashy" anyway, and IMHO it doesn't really serve a utlitarian purpose, so it likely won't affect anyone who isn't trying to be "flashy".

    What you can do though, is check to see if the client's browser supports your script by using other techniques to determine the browser type (see the javascript forum), and then, if it's supported, work your magic.

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #10
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i was adviced that the marquee sript on this iste is cross browser one, I haven't tested it myself thoug. will try at the weekend.



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

  • #11
    Regular Coder
    Join Date
    Jan 2003
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have checked the code and I had seen that was a javascript, however I wonder if I can still call the data from the database with Response.Write action within javascript. If not what can be the alternative way?


    It is something like:

    <script language="JavaScript1.2">

    //Specify the marquee's width (in pixels)
    var marqueewidth=300
    //Specify the marquee's height
    var marqueeheight=25
    //Specify the marquee's marquee speed (larger is faster 1-10)
    var marqueespeed=3
    //configure background color:
    var marqueebgcolor="#DEFDD9"
    //Pause marquee onMousever (0=no. 1=yes)?
    var pauseit=1

    //Specify the marquee's content (don't delete <nobr> tag)
    //Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

    var marqueecontent='<nobr><%

    Response.write("<font-family: Arial Narrow; font-size: 8pt>" )
    Set conn = server.createobject("adodb.connection")
    dbName="deneme.mdb"
    connect ="provider=microsoft.jet.oledb.4.0;data source="
    connect=connect & server.mappath(dbName)& ";"
    conn.open connect

    SQLstmt = "SELECT * FROM [Branch]"
    set rs = conn.Execute(SQLstmt)
    if not rs.EOF then
    rs.movefirst
    Do
    Branch_Code = (rs("Branch_Code"))
    Branch_Code = Branch_Code & "<br>"
    Response.write(Branch_Code)
    rs.movenext
    loop until rs.EOF
    End If

    'Clean Up And Close Database
    Set rs = Nothing

    Set SQLstmt = Nothing
    conn.close
    Set conn = Nothing

    Respinse.Write("Hi")
    %>
    </nobr>'



    marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
    var copyspeed=marqueespeed
    var pausespeed=(pauseit==0)? copyspeed: 0
    var iedom=document.all||document.getElementById
    if (iedom)
    document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-5000">'+marqueecontent+'</span>')
    var actualwidth=''
    var cross_marquee, ns_marquee

    function populate(){
    if (iedom){
    cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
    cross_marquee.style.left=marqueewidth+8
    cross_marquee.innerHTML=marqueecontent
    actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
    }
    else if (document.layers){
    ns_marquee=document.ns_marquee.document.ns_marquee2
    ns_marquee.left=marqueewidth+8
    ns_marquee.document.write(marqueecontent)
    ns_marquee.document.close()
    actualwidth=ns_marquee.document.width
    }
    lefttime=setInterval("scrollmarquee()",20)
    }
    window.onload=populate

    function scrollmarquee(){
    if (iedom){
    if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
    cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
    else
    cross_marquee.style.left=marqueewidth+8

    }
    else if (document.layers){
    if (ns_marquee.left>(actualwidth*(-1)+8))
    ns_marquee.left-=copyspeed
    else
    ns_marquee.left=marqueewidth+8
    }
    }

    if (iedom||document.layers){
    with (document){
    document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
    if (iedom){
    write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
    write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
    write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
    write('</div></div>')
    }
    else if (document.layers){
    write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
    write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
    write('</ilayer>')
    }
    document.write('</td></table>')
    }
    }
    </script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •