bwd Posted August 10, 2006 Share Posted August 10, 2006 I'm trying to run a script inside a new box in the right column. I can make new boxes and add box pages, but I can't figure out how to get this script to run inside a new box. I can get the script to run but not inside of a box, border, heading, etc... It just displays the selected image. <!-- random_article //--> <tr> <script Language="JavaScript"> <!-- // original script by Geoff McCausland http://www.jetlink.net/~webpro function makeArray(){ this.length = makeArray.arguments.length for (var i = 0; i < this.length; i++) this[i + 1] = makeArray.arguments[i] } var now = new Date(); var sec = now.getSeconds(); // NUM IS THE NUMBER OF BANNERS TO CHOOSE FROM var num = 2; // LIST THE URL TO LINK TO AND THE IMAGE TAG BELOW EACH ENTRY MUST BE FOLLOWED BY A COMMA EXCEPT THE LAST ENTRY WHICH NEEDS THE CLOSING PARENTHESIS AND A SEMI-COLON var bannerArray = new makeArray( '<td align="center" ><A href="http://www.mysite.com" target="_blank"><img src="images/myphoto.gif" alt="My Photo On My Site" border=0 hspace=0 vspace=0></td>', '<td align="center" ><A href="http://www.mysite.com" target="_blank"><img src="images/myphoto2.gif" alt="My Photo On My Site" border=0 hspace=0 vspace=0></td>' ); for (i = 1; i <= num; i++) { if (sec <= (i * 60 / num) && sec > ((i - 1) * 60 / num)) { document.write (bannerArray[i]); } } // --> </script> </tr> <!-- random_article_eof //--> This code randomly displays an image Thanks in advance Brian Link to comment Share on other sites More sharing options...
MoisesZaragoza Posted August 10, 2006 Share Posted August 10, 2006 do you know if you are inside of <?php ?> tags? at the end of the day the code will be good Link to comment Share on other sites More sharing options...
jhsands Posted August 10, 2006 Share Posted August 10, 2006 Put your javascript code in example.php and upload it to /includes/boxes/ Do an include in the /includes/boxes/whatever.php file you want... for the categories box it would be categories.php . include("example.php"); ?> </td> That should parse it for you. I had to this to get my GeoTrust icon to work properly, as osC would not parse the javascript directly in the information.php but parsed fine when I stuck it in geo.php and did the include. BACKUP your current files before editing. Did I mention to BACKUP your current files, first? "I'm not a hero, I'm a firefighter; it is my job to save lives. I'm a Jesus Christ Firefighter saving souls from the flames!" Installed contribs: Almost XP Buttons *** Attribute Sort *** Auto Thumbnail Change *** Column Product Listing (for SPPC v4.0) *** Contact Us Registered *** Country-State Selector 1.3.3J *** CC# Db Mask 1.3 *** Email Order Clickable Link *** Extra Images *** Linkpoint API CVM *** Loginbox Best *** New Spiders *** New Attrib Mgr v.5.0 w/ New Attrib Include *** Multi Product Update *** MySQL Cron *** Pricing per Category *** Product Listing in Columns v2.2 [later upgraded to CPL(SPPC)] *** Product Sort v1.6 *** Seperate Pricing Per Customer v4.15 *** Simple Down for Maintenance [Gokou] *** Ultimate_SEO_URLs_v2.2.2 *** UPS Worldship Export 1.3 *** Welcome Email username & password Link to comment Share on other sites More sharing options...
MoisesZaragoza Posted August 10, 2006 Share Posted August 10, 2006 try starting your file with ?> <!-- random_article //--> <tr> <script Language="JavaScript"> .... at the end of the day the code will be good Link to comment Share on other sites More sharing options...
bwd Posted August 11, 2006 Author Share Posted August 11, 2006 None of these seem to work, I am able to get the script to run, but it won't run inside of the box. I'm sure there is a way to get it to work and it's driving me crazy. I've tried it in and out of php tags, I also tried the include, but it shows it below the box not in it. The code I pasted above is what I use to just run the script, it shows, but not inside of a box. Link to comment Share on other sites More sharing options...
bwd Posted August 11, 2006 Author Share Posted August 11, 2006 So far I settled for this, but it doesn't place the image inside the box. It is just below the heading, I deleted the actual content part of the box. I did the script as follows:example.php ?> <!-- random_article //--> <tr> <script Language="JavaScript"> <!-- // original script by Geoff McCausland http://www.jetlink.net/~webpro function makeArray(){ this.length = makeArray.arguments.length for (var i = 0; i < this.length; i++) this[i + 1] = makeArray.arguments[i] } var now = new Date(); var sec = now.getSeconds(); // NUM IS THE NUMBER OF BANNERS TO CHOOSE FROM var num = 2; // LIST THE URL TO LINK TO AND THE IMAGE TAG BELOW EACH ENTRY MUST BE FOLLOWED BY A COMMA EXCEPT THE LAST ENTRY WHICH NEEDS THE CLOSING PARENTHESIS AND A SEMI-COLON var bannerArray = new makeArray( '<td align="center" ><A href="http://localhost/oscommerce/catalog/crested_gecko.php?osCsid=3a4973cb3cb72f2cc68a26d029fe3c92" target="_blank"><img src="images/crested01.gif" alt="Crested Gecko" border=1 hspace=0 vspace=0></td>', '<td align="center" ><A href="http://localhost/oscommerce/catalog/crested_gecko.php?osCsid=3a4973cb3cb72f2cc68a26d029fe3c92" target="_blank"><img src="images/crested01.gif" alt="Crested Gecko" border=1 hspace=0 vspace=0></td>' ); for (i = 1; i <= num; i++) { if (sec <= (i * 60 / num) && sec > ((i - 1) * 60 / num)) { document.write (bannerArray[i]); } } // --> </script> </tr> <!-- random_article_eof //--> And did the suggested include: test.php ?> <!-- information //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_INFORMATION); new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('text' => ''); include("example.php"); ?> </td> </tr> <!-- information_eof //--> If I get rid of any of the array lines, the box disappears completely and leaves just the image. I want it to look uniform with the rest of the boxes with the image inside of the box. Thank You both for your help so far! Brian Link to comment Share on other sites More sharing options...
bwd Posted August 11, 2006 Author Share Posted August 11, 2006 Has anyone else done anything similar? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.