Javascript in userdefined tag
Posted: Fri Feb 02, 2007 9:40 pm
Hi all,
I am a newbie to CMSMS and I need to migrate a website currently in html and php into CMSMS. I am finding huge difficulties in creating an userdefined tag that connects to the database to display some dynamic content on the page. I was basically trying to use the same html and php code into CMSMS (Not sure whether this is correct or not!!)
Actually the requirement is that there is a small table (one one side of the page) in my main page where the content needs to be taken from the database and refreshed after every fixed period of time (like flash news). So I had thought of creating an userdefined tag and use php, javascript code in that to implement this functionality. The code in the userdefined tag is below.
I guess I am doing some basic mistake in implementing this functionality but not sure what is that
. Please let me know how should I go about resolving this problem. It would be of great help in resolving this problem.
Thanks a ton in advance,
Neo
I am a newbie to CMSMS and I need to migrate a website currently in html and php into CMSMS. I am finding huge difficulties in creating an userdefined tag that connects to the database to display some dynamic content on the page. I was basically trying to use the same html and php code into CMSMS (Not sure whether this is correct or not!!)
Actually the requirement is that there is a small table (one one side of the page) in my main page where the content needs to be taken from the database and refreshed after every fixed period of time (like flash news). So I had thought of creating an userdefined tag and use php, javascript code in that to implement this functionality. The code in the userdefined tag is below.
Code: Select all
require_once('../Connections/gwriDB.php');
mysql_select_db($database_gwriDB, $gwriDB);
$query_RsFacts = "SELECT * FROM Facts ORDER BY Facts.`Order`";
$RsFacts = mysql_query($query_RsFacts, $gwriDB) or die(mysql_error());
$row_RsFacts = mysql_fetch_assoc($RsFacts);
$totalRows_RsFacts = mysql_num_rows($RsFacts);
{literal}
<__script__ language="JavaScript1.2">
//IFRAME TICKER- By Dynamic Drive (http://www.dynamicdrive.com)
//configure delay between changing messages (3000=3 seconds)
var delay=15000
var ie4=document.all
var curindex=0
var totalcontent=0
function get_total(){
if (ie4){
while (eval("document.all.content"+totalcontent))
totalcontent++
}
else{
while (document.getElementById("content"+totalcontent))
totalcontent++
}
}
function contract_all(){
for (y=0;y<totalcontent;y++){
if (ie4)
eval("document.all.content"+y).style.display="none"
else
document.getElementById("content"+y).style.display="none"
}
}
function expand_one(which){
contract_all()
if (ie4)
eval("document.all.content"+which).style.display=""
else
document.getElementById("content"+which).style.display=""
}
function rotate_content(){
get_total()
contract_all()
expand_one(curindex)
curindex=(curindex<totalcontent-1)? curindex+1: 0
setTimeout("rotate_content()",delay)
}
window.onload=rotate_content
</__script>
{/literal}
<link href="../Common/GWRI_CSS.css" rel="stylesheet" type="text/css">
</__body bgColor=#F4FDFF text="#990000" link="#990000" vlink="#990000" alink="#990000">
<!--ADD YOUR TICKER CONTENT BELOW, by wrapping each one inside a <DIV> as shown below.-->
<!--For each DIV, increment its ID attribute for each additional content (ie: "content1", "content2" etc)-->
$thiscont = -1
<!-- ADD TICKER's CONTENT #1 HERE--------------------->
do {
$thiscont = $thiscont + 1;
$thiscontstr = "content" . $thiscont;
printf("<div id='%s' style='display:'''><p class='InterestingFact'> %s</p></div>", $thiscontstr, $row_RsFacts['Fact']);
} while ($row_RsFacts = mysql_fetch_assoc($RsFacts));
mysql_free_result($RsFacts);

Thanks a ton in advance,
Neo