integrating CMS into Javascript code.
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 26, 2011 (RSS)
By (Deleted User) - April 25, 2011 - edited: April 25, 2011
I am pulling in quotes using Javascript as below:
===============================
<script type="text/javascript">
var speed=8000;
var c=0;
function showQuote() {
quotes=[
'<p id="text">"Quote Number 1."<\/p>'+
'<p id="name" align="right">- Name,Title<\/p>',
'<p id="text">"Quote 2"<\/p>'+
'<p id="name" align="right">- Steve, Ontario<\/p>',
'<p id="text">"Quote 3."<\/p>'+
'<p id="name" align="right">- Dave, Los Angeles<\/p>'
];
c++;
if(c==quotes.length) {
c=0;
}
document.getElementById('quote').innerHTML=quotes[c];
setTimeout(function(){showQuote()},speed);
}
if(window.addEventListener){
window.addEventListener('load',function(){setTimeout(function(){showQuote()},speed)},false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',function(){setTimeout(function(){showQuote()},speed)});
}
}
</script>
===================================
and in the HTML
===================================
<p id="text">"ATI has a well-earned reputation for providing outstanding T5 fixtures."</p>
<p id="name" align="right">- Reef Tools</p>
====================================
This is working great. I tried to add my CMS code with mixed results, so I am turning to the forums hoping someone can help...
Below is the code for each record... Thanks!
<?php foreach ($quotesRecords as $record): ?>
<?php echo $record['quote'] ?>
<?php echo $record['title'] ?>
<?php endforeach ?>
===============================
<script type="text/javascript">
var speed=8000;
var c=0;
function showQuote() {
quotes=[
'<p id="text">"Quote Number 1."<\/p>'+
'<p id="name" align="right">- Name,Title<\/p>',
'<p id="text">"Quote 2"<\/p>'+
'<p id="name" align="right">- Steve, Ontario<\/p>',
'<p id="text">"Quote 3."<\/p>'+
'<p id="name" align="right">- Dave, Los Angeles<\/p>'
];
c++;
if(c==quotes.length) {
c=0;
}
document.getElementById('quote').innerHTML=quotes[c];
setTimeout(function(){showQuote()},speed);
}
if(window.addEventListener){
window.addEventListener('load',function(){setTimeout(function(){showQuote()},speed)},false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',function(){setTimeout(function(){showQuote()},speed)});
}
}
</script>
===================================
and in the HTML
===================================
<p id="text">"ATI has a well-earned reputation for providing outstanding T5 fixtures."</p>
<p id="name" align="right">- Reef Tools</p>
====================================
This is working great. I tried to add my CMS code with mixed results, so I am turning to the forums hoping someone can help...
Below is the code for each record... Thanks!
<?php foreach ($quotesRecords as $record): ?>
<?php echo $record['quote'] ?>
<?php echo $record['title'] ?>
<?php endforeach ?>
Re: [kimamel] integrating CMS into Javascript code.
By Jason - April 26, 2011
Hi,
When you put in the PHP code, what results are you getting? Is it giving you errors?
Could you attach your .php file so we can take a look at the code you are using?
Thanks
When you put in the PHP code, what results are you getting? Is it giving you errors?
Could you attach your .php file so we can take a look at the code you are using?
Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/