melkordy
asked on
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;wi dth:"+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:0p x; 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:0p x;\"";
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.getElementBy Id('d'+gnu m);
objd2=document.getElementB yId('hgd'+ gnum);
objd.style.color="#3A3A3A" ;
objd2.style.color="#D50000 ";
objd.style.cursor='pointer ';
objd2.style.cursor='pointe r';
objd.style.textDecoration= 'none';obj d2.style.t extDecorat ion='none' ;
window.status=""+linka[gnu m];
}
}
function restime(gnum2)
{
inoout=false;
objd=document.getElementBy Id('d'+gnu m2);
objd2=document.getElementB yId('hgd'+ gnum2);
objd.style.color="#000000" ;
objd2.style.color="#9A0000 ";
objd.style.textDecoration= 'none';obj d2.style.t extDecorat ion='none' ;
window.status="";
}
function butclick(gnum3)
{
if(linka[gnum3].substring( 0,11)=="ja vascript:" ){eval(""+ linka[gnum 3]);}else{ if((linka[ gnum3].len gth)>3){
if((trgfrma[gnum3].indexOf ("_parent" )>-1)){eva l("parent. window.loc ation='"+l inka[gnum3 ]+"'");}el se if((trgfrma[gnum3].indexOf ("_top")>- 1)){eval(" top.window .location= '"+linka[g num3]+"'") ;}else{win dow.open(' '+linka[gn um3],''+tr gfrma[gnum 3]);}}}
}
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()',300 0+35);
}
else
{
setTimeout('dotrans()',35) ;
}
}
function initte2()
{
i=0;
for(i=0;i<mc;i++)
{
objd=document.getElementBy Id('d'+i);
heightarr[i]=objd.offsetHe ight;
}
toplay=4;
for(i=0;i<mc;i++)
{
objd=document.getElementBy Id('d'+i);
objd.style.visibility="vis ible";
objd.style.top=""+toplay+" px";
psy[toplay]=3;
toplay=toplay+heightarr[i] +10;
}
uzunobj=document.getElemen tById('enu zun');
uzunobj.style.left=8+"px";
uzunobj.style.height=topla y+"px";
uzunobj.style.width=tmpv+" px";
uzuntop=150;
dotrans();
}
function initte()
{
i=0;
innertxt=""+uzun;
for(i=0;i<mc;i++)
{
innertxt=innertxt+""+divte xtb+""+i+" "+divtev1+ i+divtev2+ i+divtev3+ i+divtev4+ divtexts+" <div id=\"hgd"+i+"\""+ns6span+" >"+titlea[ i]+"<br></ div>"+text a[i]+"</di v>";
}
innertxt=innertxt+"</div>" ;
spage=document.getElementB yId('spage ns');
spage.innerHTML=""+innertx t;
spage.style.left="0px";
spage.style.top="0px";
setTimeout('initte2()',500 );
}
window.onload=initte;
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]=
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=
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;
ns6span= " style=\"position:relative;
uzun="<div id=\"enuzun\" style=\"position:absolute;
var uzunobj=null;
var uzuntop=0;
var toplay=0;
function mdivmo(gnum)
{
inoout=true;
if((linka[gnum].length)>2)
{
objd=document.getElementBy
objd2=document.getElementB
objd.style.color="#3A3A3A"
objd2.style.color="#D50000
objd.style.cursor='pointer
objd2.style.cursor='pointe
objd.style.textDecoration=
window.status=""+linka[gnu
}
}
function restime(gnum2)
{
inoout=false;
objd=document.getElementBy
objd2=document.getElementB
objd.style.color="#000000"
objd2.style.color="#9A0000
objd.style.textDecoration=
window.status="";
}
function butclick(gnum3)
{
if(linka[gnum3].substring(
if((trgfrma[gnum3].indexOf
}
function dotrans()
{
if(inoout==false){
uzuntop--;
if(uzuntop<(-1*toplay))
{
uzuntop=150;
}
uzunobj.style.top=uzuntop+
}
if(psy[(uzuntop*(-1))+4]==
{
setTimeout('dotrans()',300
}
else
{
setTimeout('dotrans()',35)
}
}
function initte2()
{
i=0;
for(i=0;i<mc;i++)
{
objd=document.getElementBy
heightarr[i]=objd.offsetHe
}
toplay=4;
for(i=0;i<mc;i++)
{
objd=document.getElementBy
objd.style.visibility="vis
objd.style.top=""+toplay+"
psy[toplay]=3;
toplay=toplay+heightarr[i]
}
uzunobj=document.getElemen
uzunobj.style.left=8+"px";
uzunobj.style.height=topla
uzunobj.style.width=tmpv+"
uzuntop=150;
dotrans();
}
function initte()
{
i=0;
innertxt=""+uzun;
for(i=0;i<mc;i++)
{
innertxt=innertxt+""+divte
}
innertxt=innertxt+"</div>"
spage=document.getElementB
spage.innerHTML=""+innertx
spage.style.left="0px";
spage.style.top="0px";
setTimeout('initte2()',500
}
window.onload=initte;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>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.
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.
ASKER
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"></sc ript> 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;wi dth:"+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:0p x; 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:0p x;\"";
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';obj d2.style.t extDecorat ion='none' ;
}
window.status=""+linka[gnu m];
}
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';obj d2.style.t extDecorat ion='none' ;
window.status="";
}
function butclick(gnum3)
{
if(linka[gnum3].substring( 0,11)=="ja vascript:" ){eval(""+ linka[gnum 3]);}else{ if((linka[ gnum3].len gth)>3){
if((trgfrma[gnum3].indexOf ("_parent" )>-1)){eva l("parent. window.loc ation='"+l inka[gnum3 ]+"'");}el se if((trgfrma[gnum3].indexOf ("_top")>- 1)){eval(" top.window .location= '"+linka[g num3]+"'") ;}else{win dow.open(' '+linka[gn um3],''+tr gfrma[gnum 3]);}}}
}
function dotrans()
{
if(inoout==false){
uzuntop--;
if(uzuntop<(-1*toplay))
{
uzuntop=150;
}
enuzun.style.pixelTop=uzun top;
}
if(psy[(uzuntop*(-1))+4]== 3)
{
setTimeout('dotrans()',300 0+35);
}
else{setTimeout('dotrans() ',35);}
}
function initte2()
{
i=0;
for(i=0;i<mc;i++)
{
objd=eval("d"+i);
heightarr[i]=objd.offsetHe ight;
}
toplay=4;
for(i=0;i<mc;i++)
{
objd=eval("d"+i);
objd.style.visibility="vis ible";
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+"p x";
uzuntop=150;
dotrans();
}
function initte()
{
i=0;
innertxt=""+uzun;
for(i=0;i < mc;i++)
{
innertxt=innertxt+""+divte xtb+""+i+" "+divtev1+ i+divtev2+ i+divtev3+ i+divtev4+ divtexts+" <span id=\"hgd"+i+"\""+ie6span+" >"+titlea[ i]+"</span ><br>"+tex ta[i]+"</d iv>";
}
innertxt=innertxt+"</div>" ;
spageie.innerHTML=""+inner txt;
setTimeout('initte2()',500 );
}
window.onload=initte;
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"></sc
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=
var psy = new Array();
divtextb ="<div id=d";
divtev1=" onmouseover=\"mdivmo(";
divtev2=")\" onmouseout =\"restime(";
divtev3=")\" onclick=\"butclick(";
divtev4=")\"";
divtexts = " style=\"position:absolute;
ie6span= " style=\"position:relative;
uzun="<div id=\"enuzun\" style=\"position:absolute;
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=
}
window.status=""+linka[gnu
}
function restime(gnum2)
{
inoout=false;
objd=eval("d"+gnum2);
objd2=eval("hgd"+gnum2);
objd.style.color="#000000"
objd2.style.color="#9A0000
objd.style.textDecoration=
window.status="";
}
function butclick(gnum3)
{
if(linka[gnum3].substring(
if((trgfrma[gnum3].indexOf
}
function dotrans()
{
if(inoout==false){
uzuntop--;
if(uzuntop<(-1*toplay))
{
uzuntop=150;
}
enuzun.style.pixelTop=uzun
}
if(psy[(uzuntop*(-1))+4]==
{
setTimeout('dotrans()',300
}
else{setTimeout('dotrans()
}
function initte2()
{
i=0;
for(i=0;i<mc;i++)
{
objd=eval("d"+i);
heightarr[i]=objd.offsetHe
}
toplay=4;
for(i=0;i<mc;i++)
{
objd=eval("d"+i);
objd.style.visibility="vis
objd.style.pixelTop=toplay
psy[toplay]=3;
toplay=toplay+heightarr[i]
}
enuzun.style.left=8+"px";
enuzun.style.height=toplay
enuzun.style.width=tmpv+"p
uzuntop=150;
dotrans();
}
function initte()
{
i=0;
innertxt=""+uzun;
for(i=0;i < mc;i++)
{
innertxt=innertxt+""+divte
}
innertxt=innertxt+"</div>"
spageie.innerHTML=""+inner
setTimeout('initte2()',500
}
window.onload=initte;
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...