forummaker Posted September 12, 2010 Posted September 12, 2010 Hi all. I'm trying to add the following javascript code from here: LINK HERE I have all the code in place... but I just can't figure out the actual body code part, which is: <img src="" id="myimage" alt="time of day"> Here's what I'm doing. I added a new banner to the left of my page. This banner will only show at certain times of the day. ie. between the hours of 9am to 5pm. This will allow me to have a "Call in your order" banner that will only display during those times of the day. Because it is a banner, using the banner manager, I can also disable the banner at any time during the day or all weekend if I want to. I have added all the necessary code as required to get it working... but, I can't figure out one part. The code I indicated above. Again, I don't know what to put in here: <img src="WHAT GOES HERE?" id="myimage" alt="time of day"> Any help with this would be great. This may also help anyone looking for something similar. Thanks a bunch. Quote That "Can" you're about to open... has worms! Don't say I didn't worn ya. n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.
web-project Posted September 12, 2010 Posted September 12, 2010 <img src="WHAT GOES HERE?" id="myimage" alt="time of day"> you need to use php code to check the time, if it's certain time than display your image. Quote Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here! 8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself. Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues. Any issues with oscommerce, I am here to help you.
forummaker Posted September 12, 2010 Author Posted September 12, 2010 you need to use php code to check the time, if it's certain time than display your image. Isn't that all handled through the .js file? Here's the code in a nutshell.... Add this to index.php: - add before </head> <script type="text/javascript" src="timePictureChange.js"></script> - Create and add this .js file into root: function pixTimeChange() { var t=new Date(); var h = t.getHours(); var r1="pic1.gif"; var r2="pic2.gif"; var el=document.getElementById('myimage'); // See the time below. Note: The time is in 24 hour format. // In the example here, "7" = 7 AM; "17" =5PM. el.src = (h>=7 && h<17) ? r1 : r2; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { pixTimeChange(); }); - Add this code into body: <img src="" id="myimage" alt="time of day"> Again, I think I'm just not adding the proper <img src="?"... hmmm.... Thanks. Quote That "Can" you're about to open... has worms! Don't say I didn't worn ya. n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.