How would i get a "news".js file to populate its multidimensional array from a sql table?

Good morning experts,

I got this software that generates nice looking scrolling news scripts for me.  I want to be able to feed those scripts from a sql table where users can input information to it through a form.  I don't know if this could be done in .js files.

Can i include .asp or .cfm files in .js?

Here is one of the scripts that this software creates.

//news.js file

var titlea = new Array();var texta = new Array();var linka = new Array();var trgfrma = new Array();var heightarr = new Array();var cyposarr = new Array();


//news items
cyposarr[0]=0;cyposarr[1]=1;//start a new array

titlea[0] = "title";texta[0] = "headline";linka[0] = "url";trgfrma[0] = "";
titlea[1] = "title";texta[1] = "headline";linka[1] = "url";trgfrma[1] = "";

var mc=2;//how many elements

//news items






var inoout=false;

var spage;
var cvar=0,say=0,tpos=0,enson=0,hidsay=0,hidson=0;
var tmpv;
tmpv=236-8-8-(2*0);

var psy = new Array();
divtextb ="<div id=d";
divtev1=" onmouseover=\"mdivmo(";
divtev2=")\" onmouseout =\"restime(";
divtev3=")\" onclick=\"butclick(";
divtev4=")\"";
divtexts = " style=\"position:absolute;visibility:hidden;width:"+tmpv+"; COLOR: 000000; left:0; top:0; FONT-FAMILY: Arial; FONT-SIZE: 8pt; FONT-STYLE: normal; FONT-WEIGHT: normal; TEXT-DECORATION: none; margin:0px; overflow-x:hidden; LINE-HEIGHT: 12pt; text-align:left;padding:0px; cursor:'default';\">";
ns6span= " style=\"position:relative; COLOR: 9A0000; width:"+tmpv+"; FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-WEIGHT: bold; TEXT-DECORATION: none; LINE-HEIGHT: 14pt; text-align:left;padding:0px;\"";

uzun="<div id=\"enuzun\" style=\"position:absolute;left:0;top:0;\">";
var uzunobj=null;
var uzuntop=0;
var toplay=0;

function mdivmo(gnum)
{
      inoout=true;

      if((linka[gnum].length)>2)
      {
            objd=document.getElementById('d'+gnum);
            objd2=document.getElementById('hgd'+gnum);

            objd.style.color="#3A3A3A";
            objd2.style.color="#D50000";

            objd.style.cursor='pointer';
            objd2.style.cursor='pointer';

            objd.style.textDecoration='none';objd2.style.textDecoration='none';

            window.status=""+linka[gnum];
      }
}

function restime(gnum2)
{
      inoout=false;
      
      objd=document.getElementById('d'+gnum2);
      objd2=document.getElementById('hgd'+gnum2);

      objd.style.color="#000000";
      objd2.style.color="#9A0000";

      objd.style.textDecoration='none';objd2.style.textDecoration='none';

      window.status="";
}

function butclick(gnum3)
{
if(linka[gnum3].substring(0,11)=="javascript:"){eval(""+linka[gnum3]);}else{if((linka[gnum3].length)>3){
if((trgfrma[gnum3].indexOf("_parent")>-1)){eval("parent.window.location='"+linka[gnum3]+"'");}else if((trgfrma[gnum3].indexOf("_top")>-1)){eval("top.window.location='"+linka[gnum3]+"'");}else{window.open(''+linka[gnum3],''+trgfrma[gnum3]);}}}

}

function dotrans()
{
      if(inoout==false){

      uzuntop--;
      if(uzuntop<(-1*toplay))
      {
            uzuntop=150;
      }

      uzunobj.style.top=uzuntop+"px";
}
      if(psy[(uzuntop*(-1))+4]==3)
      {
            setTimeout('dotrans()',3000+35);
      }
      else
      {
            setTimeout('dotrans()',35);
      }      
      
}


function initte2()
{
      i=0;
      for(i=0;i<mc;i++)
      {
            objd=document.getElementById('d'+i);
            heightarr[i]=objd.offsetHeight;
      }
      toplay=4;
      for(i=0;i<mc;i++)
      {
            objd=document.getElementById('d'+i);
            objd.style.visibility="visible";
            objd.style.top=""+toplay+"px";
            psy[toplay]=3;
            toplay=toplay+heightarr[i]+10;

      }

      uzunobj=document.getElementById('enuzun');
      uzunobj.style.left=8+"px";
      uzunobj.style.height=toplay+"px";
      uzunobj.style.width=tmpv+"px";
      uzuntop=150;
      dotrans();

}

function initte()
{
      i=0;
      innertxt=""+uzun;

      for(i=0;i<mc;i++)
      {
            innertxt=innertxt+""+divtextb+""+i+""+divtev1+i+divtev2+i+divtev3+i+divtev4+divtexts+"<div id=\"hgd"+i+"\""+ns6span+">"+titlea[i]+"<br></div>"+texta[i]+"</div>";
      }
      innertxt=innertxt+"</div>";
      spage=document.getElementById('spagens');

      spage.innerHTML=""+innertxt;

      spage.style.left="0px";
      spage.style.top="0px";

      setTimeout('initte2()',500);

}


window.onload=initte;
melkordyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
>>Can i include .asp or .cfm files in .js?

try do it in this way...

try rename your .js file to .asp or .cfm file, so that it can be run on server side. Since it's running on server side, you can generate the portion of js file dynamically via server side scripting.

Get the idea?

Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrichmonCommented:
>>Can i include .asp or .cfm files in .js?
NO.

You cannot!

They must be processed by the server, whereas .js is a javascript file that is only run on the client.

Now you can have variables sent from asp or cfm to the js.  not to the file, but into variables, that thte file can read...
0
Ryan ChongCommented:
>>try rename your .js file to .asp or .cfm file, so that it can be run on server side
yup, rename it so that it can run on server side, and then use it as an include file to your original page. Hope this is clear.
0
melkordyAuthor Commented:
I changed the .js to .cfm

the .cfm page have no html tags only the code below.  when i add the HTML tags or <cfquery> it just stopped running.  I put that code within <script langauage"javascript"></script> tags and it didn't do nothing.  any hints?






var titlea = new Array();var texta = new Array();var linka = new Array();var trgfrma = new Array();var heightarr = new Array();var cyposarr = new Array();

cyposarr[0]=0;
titlea[0] = "title";texta[0] = "headline";linka[0] = "url";trgfrma[0] = " ";
var mc=1;



var inoout=false;
var tmpv;
tmpv=236-8-8-2*parseInt(0);
var cvar=0,say=0,tpos=0,enson=0,hidsay=0,hidson=0;
var psy = new Array();
divtextb ="<div id=d";
divtev1=" onmouseover=\"mdivmo(";
divtev2=")\" onmouseout =\"restime(";
divtev3=")\" onclick=\"butclick(";
divtev4=")\"";
divtexts = " style=\"position:absolute;visibility:hidden;width:"+tmpv+"; COLOR: #000000; left:0; top:0; FONT-FAMILY: Arial; FONT-SIZE: 8pt; FONT-STYLE: normal; FONT-WEIGHT: normal; TEXT-DECORATION: none; margin:0px; overflow-x:hidden; LINE-HEIGHT: 12pt; text-align:left;padding:0px; cursor:'default';\">";
ie6span= " style=\"position:relative; COLOR: #9A0000; width:"+tmpv+"; FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-WEIGHT: bold; TEXT-DECORATION: none; LINE-HEIGHT: 14pt; text-align:left;padding:0px;\"";
uzun="<div id=\"enuzun\" style=\"position:absolute;left:0;top:0;\">";
var uzunobj=null;
var uzuntop=0;
var toplay=0;
function mdivmo(gnum)
{
      inoout=true;

      if((linka[gnum].length)>2)
      {
      objd=eval("d"+gnum);
      objd2=eval("hgd"+gnum);

      objd.style.color="#3A3A3A";
      objd2.style.color="#D50000";

      objd.style.cursor='hand';
      objd2.style.cursor='hand';

      objd.style.textDecoration='none';objd2.style.textDecoration='none';

}
      window.status=""+linka[gnum];

}

function restime(gnum2)
{
      inoout=false;
      objd=eval("d"+gnum2);
      objd2=eval("hgd"+gnum2);

      objd.style.color="#000000";
      objd2.style.color="#9A0000";

      objd.style.textDecoration='none';objd2.style.textDecoration='none';

      window.status="";

}

function butclick(gnum3)
{
if(linka[gnum3].substring(0,11)=="javascript:"){eval(""+linka[gnum3]);}else{if((linka[gnum3].length)>3){
if((trgfrma[gnum3].indexOf("_parent")>-1)){eval("parent.window.location='"+linka[gnum3]+"'");}else if((trgfrma[gnum3].indexOf("_top")>-1)){eval("top.window.location='"+linka[gnum3]+"'");}else{window.open(''+linka[gnum3],''+trgfrma[gnum3]);}}}


}

function dotrans()
{
      if(inoout==false){
      uzuntop--;
      if(uzuntop<(-1*toplay))
      {
            uzuntop=150;
      }

      enuzun.style.pixelTop=uzuntop;
}
      if(psy[(uzuntop*(-1))+4]==3)
      {
setTimeout('dotrans()',3000+35);
}
else{setTimeout('dotrans()',35);}

}

function initte2()
{
      i=0;
      for(i=0;i<mc;i++)
      {
            objd=eval("d"+i);
            heightarr[i]=objd.offsetHeight;
      }

      toplay=4;
      for(i=0;i<mc;i++)
      {
            objd=eval("d"+i);
            objd.style.visibility="visible";
            objd.style.pixelTop=toplay;
            psy[toplay]=3;
            toplay=toplay+heightarr[i]+10;

      }


      enuzun.style.left=8+"px";
      enuzun.style.height=toplay+"px";
      enuzun.style.width=tmpv+"px";
      uzuntop=150;



      dotrans();

}

function initte()
{
      i=0;
      innertxt=""+uzun;
      for(i=0;i < mc;i++)
      {
            innertxt=innertxt+""+divtextb+""+i+""+divtev1+i+divtev2+i+divtev3+i+divtev4+divtexts+"<span id=\"hgd"+i+"\""+ie6span+">"+titlea[i]+"</span><br>"+texta[i]+"</div>";
      }
      innertxt=innertxt+"</div>";

      spageie.innerHTML=""+innertxt;
      setTimeout('initte2()',500);
}
window.onload=initte;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.