I have this script and I am trying to create a third value (m3) but I do not know what to do with the obj.nodeValue=(obj.nodeValue==m1)?m2:m1; line.
Also how would I go about putting html in m1, m2 and m3? specifically the bold tag.
Thanks
<script type="text/javascript">
function adMessage() {
delay=10000;
m1='Place your Thanksgiving orders today!';
m2='All orders must be received by November 20th!';
m3='testing';
obj=document.getElementById('orders').firstChild;
obj.nodeValue=(obj.nodeValue==m1)?m2:m1;
setTimeout(function(){adMessage()},delay);
}
if(window.addEventListener){
window.addEventListener('load',adMessage,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',adMessage);
}
}
</script>
<p id="orders">Place your Thanksgiving orders today!</p>
The line
is a short version of this
Depending on your logic to display the m3 value you need to extend this decision.
If you want to switch to the next message at each interval then maybe this is your solution:
And the idea of Felix is of course better. If you put your messages in an array you can easily extend it.
For your part of the question about embedding HTML tags: you need to set innerHTML value of the element instead of nodeValue.
I put up a running jsfiddle with all aspects of your question: http://jsfiddle.net/eNape/1/