[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Scrolling Text Stored in a SQL Database

Hello,

I am trying to create an application of a home page with a small window that has scrolling text of publications abstracts stored in a SQL database.  Now I have to hand code every abstracts into the javascript code, I am just wondering how can I pull these abstracts from a SQL database?

<script language="javascript">
                        var scrollerwidth="170"
                        var scrollerheight="450"
                        var scrollerspeed="1";
                        var scrollercontent="I have to hand code the contents here "

                        var pauseit=1
                        
                        scrollerspeed=(document.all)? scrollerspeed : Math.max(1, scrollerspeed-1) //slow speed down by 1 for NS
                        var copyspeed=scrollerspeed
                        var iedom=document.all||document.getElementById
                        var actualheight=''
                        var cross_scroller, ns_scroller
                        var pausespeed=(pauseit==0)? copyspeed: 0

                        function populate(){
                        if (iedom){
                        cross_scroller=document.getElementById? document.getElementById("iescroller") : document.all.iescroller
                        cross_scroller.style.top=parseInt(scrollerheight)+8+"px"
                        cross_scroller.innerHTML=scrollercontent
                        actualheight=cross_scroller.offsetHeight
                        }
                        else if (document.layers){
                        ns_scroller=document.ns_scroller.document.ns_scroller2
                        ns_scroller.top=parseInt(scrollerheight)+8
                        ns_scroller.document.write(scrollercontent)
                        ns_scroller.document.close()
                        actualheight=ns_scroller.document.height
                        }
                        lefttime=setInterval("scrollscroller()",20)
                        }
                        // window.onload=populate

                        function scrollscroller(){

                        if (iedom){
                        if (parseInt(cross_scroller.style.top)>(actualheight*(-1)+8))
                        cross_scroller.style.top=parseInt(cross_scroller.style.top)-copyspeed+"px"
                        else
                        cross_scroller.style.top=parseInt(scrollerheight)+8+"px"
                        }
                        else if (document.layers){
                        if (ns_scroller.top>(actualheight*(-1)+8))
                        ns_scroller.top-=copyspeed
                        else
                        ns_scroller.top=parseInt(scrollerheight)+8
                        }
                        }

                        if (iedom||document.layers){
                        with (document){
                        if (iedom){
                        write('<div style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=scrollerspeed">')
                        write('<div id="iescroller" style="position:absolute;left:0px;top:0px;width:100%;">')
                        write('</div></div>')
                        }
                        else if (document.layers){
                        write('<ilayer width='+scrollerwidth+' height='+scrollerheight+' name="ns_scroller">')
                        write('<layer name="ns_scroller2" width='+scrollerwidth+' height='+scrollerheight+' left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=scrollerspeed"></layer>')
                        write('</ilayer>')
                        }
                        }
                        }
                        </script>
0
yenmei
Asked:
yenmei
  • 3
1 Solution
 
stu_pbCommented:
The only way you can read from the SQL database is with Server Side code.  When the page is generated you could create a hidden variable that contains the text of the abstracts.

<input type='hidden' id='hiddenAbstracts' name='hiddenAbstracts' value='<%=Rs("Abstract")%>'></input>

Then in your javascript code you can reference the abstracts like so:

var scrollercontent = document.all.hiddenAbstracts.value;

For multiples you could just use a delimiting character in the abstract string and use the split javascript function.

Good Luck!
0
 
justinbilligCommented:
though i wouldnt use document.all.hiddenAbstracts.value becuase that is I only

you can use

document.formname.hiddenAbstracts.value

or document.forms[ 'formname' ].elements[ 'hiddenAbstracts' ].value
0
 
justinbilligCommented:
err that was riddidled with spelling errors,

i was trying to say that document.all is IE Only, so use either of those examples in stu's example
0
 
g_damodarCommented:
If u want to get the data from the server using an html file you need to use remote scripting concept. Please see the below example to get an understanding of remote scripting
http://www.ashleyit.com/rs/jsrs/test.htm. The code is used to return a simple string and you can change the logic to get the string from the database
0
 
justinbilligCommented:
eh i believe that remote scripting is a little over the top for what he needs. You can just get it from your ASP page and give it to the html
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now