473,320 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Two Scripts Seem Incompatible on One Page - What Can I Do?

Hi,

I am trying to make a page which has both a javascript dropdown menu and a javascript rainbow coloured sentence on it. The sentence works fine on its own, but when I add the menu the whole thing crashes. I am VERY new to javascript and am not a programmer, but an artist using Javascript to explore certain concepts. If you help me with this program I would give full credit to you of course.

Here is the rainbow coloured sentence on its own, which works fine:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <!-- [Part 1] - Paste this into <HEAD> of your HTML . -->
  3.  
  4. <script type="text/javascript">
  5. /*   Color Change Text
  6. This script and many more sourced from - 
  7. http://rainbow.arch.scriptmania.com/scripts/ 
  8. */
  9.  
  10. //   Change next line for your text msg.
  11.  
  12. var msg = 'thirtyone letters changing colours'
  13. var colorTimer = null;
  14.  
  15. //  Color can be altered below - eg. remove - ABCDEF = darker
  16.  
  17. function toHex(n){
  18. var hexChars = '0123456789ABCDEF';
  19. if (n == 0) return n;
  20. var j, k;
  21. var temp = '';
  22. while (n != 0){
  23. j = n % 16;
  24. n = (n - j)/16;
  25. temp = hexChars.charAt(j) + temp;
  26. }
  27. return temp;
  28. }
  29. function colorize(){
  30. if (!document.getElementById) return;
  31. for (i=0; i<msg.length; i++){
  32. k = Math.round(Math.random() * 16777215);
  33. k = toHex(k);
  34. while (k.length < 6){
  35. k = k + '0';
  36. }
  37. document.getElementById('colorizer' + i).style.color = '#' + k;
  38. }
  39.  
  40. //  Speed change below - Default = 200 - Lower = Faster 
  41.  
  42. colorTimer = window.setTimeout('colorize()', 200);
  43. }
  44. </script>
  45.  
  46. </head>
  47.  
  48. <!-- [Part 2] Add onload to <BODY> tag.-->
  49.  
  50. <BODY onload='colorize();'>
  51.  
  52. <br>
  53. <br>
  54. <br>
  55. <br>
  56. <br>
  57. <br>
  58. <br>
  59. <br>
  60. <br>
  61. <br>
  62.  
  63. <!-- [Part 3] Paste this where you wish text to appear. -->
  64. <!-- Change style to your choice -->
  65.  
  66. <div id="text" style="font-size:large; font-family: 'Helvetica', Courier, monospace; font-size:30; letter-spacing:+1; font-style:normal; text-align:center; padding-top:15px;">
  67. <script>
  68. for (var i=0; i<msg.length; i++){
  69. document.write("<span id ='colorizer" + i + "'>" + msg.charAt(i) + "</span>");
  70. }
  71. </script></div>
  72.  
But when I put the Javacript menu I want in it stops working (but the menu works fine on its own too). The coloured letters show up when I put the BODY information for the menu in (and the menu shows up, kinda, but without the dropdown effect) but when I put the HEAD information in (which gives it the dropdown effect) the coloured sentence vanishes and all I get is the menu. I can't for the life of me figure it out. Here is the full code for the HEAD:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2.  
  3.   <meta content="text/html; charset=ISO-8859-1"
  4.  http-equiv="content-type">
  5.  
  6. <title>Thirty One Letters Changing Colours</title>
  7.  
  8. <!-- HERE IS THE MENU HEAD INFORMATION - THIS IS WHAT STOPS THE COLOURED LETTERS FROM WORKING -->
  9.  
  10. <script type="text/javascript" src="jquery.min.js"></script>
  11.  
  12. <link rel="stylesheet" type="text/css" href="jkoutlinemenu.css" />
  13.  
  14. <script type="text/javascript" src="jkoutlinemenu.js">
  15.  
  16. /***********************************************
  17. * Animated Outline Menu- by JavaScript Kit (www.javascriptkit.com)
  18. * This notice must stay intact for usage
  19. * Visit JavaScript Kit at http://www.javascriptkit.com/ for full source code
  20. ***********************************************/
  21.  
  22. <!-- HERE IS THE COLOURED LETTERS HEAD CODE -->
  23. <!-- [Part 1] - Paste this into <HEAD> of your HTML . -->
  24.  
  25. <script type="text/javascript">
  26. /*   Color Change Text
  27. This script and many more sourced from - 
  28. http://rainbow.arch.scriptmania.com/scripts/ 
  29. */
  30.  
  31. //   Change next line for your text msg.
  32.  
  33. var msg = 'thirtyone letters changing colours'
  34. var colorTimer = null;
  35.  
  36. //  Color can be altered below - eg. remove - ABCDEF = darker
  37.  
  38. function toHex(n){
  39. var hexChars = '0123456789ABCDEF';
  40. if (n == 0) return n;
  41. var j, k;
  42. var temp = '';
  43. while (n != 0){
  44. j = n % 16;
  45. n = (n - j)/16;
  46. temp = hexChars.charAt(j) + temp;
  47. }
  48. return temp;
  49. }
  50. function colorize(){
  51. if (!document.getElementById) return;
  52. for (i=0; i<msg.length; i++){
  53. k = Math.round(Math.random() * 16777215);
  54. k = toHex(k);
  55. while (k.length < 6){
  56. k = k + '0';
  57. }
  58. document.getElementById('colorizer' + i).style.color = '#' + k;
  59. }
  60.  
  61. //  Speed change below - Default = 200 - Lower = Faster 
  62.  
  63. colorTimer = window.setTimeout('colorize()', 200);
  64. }
  65. </script>
  66.  
  67. </head>
  68.  
Any help would be appreciated. I have tried putting the menu HEAD info after the coloured letters, but it still breaks. And as I have said I tried removing the menu piece by piece and it is the HEAD info which crashes the coloured letters.

Many thanks in advance for any help.

All the best,
Dick Whyte
Mar 7 '10 #1
1 1808
tpgames
785 512MB
Usually, if you change the variable names in one script to be DIFFERENT from the other script, this solves the problem. For example, add zxc or some other letter combination to names in 1 script.
Expand|Select|Wrap|Line Numbers
  1. // var zxcColumns=4; // the default number of image display columns
  2.  
  3. var zxcHofFMax=10; // the maximum number of entries in the 'Hall of Fame'
  4.  
  5. // The Cookie Code
  6. var zxcDays=90; // days before the cookie expires
  7. var zxcCookie='GlobalWritersClubCookie'; // Your chosen cookie name
  8.  
  9.  
  10. // Functional Code - No Need to Change
  11.  
  12. var zxcStdImg,zxcFnd,zxcAtp,zxcTme,zxcMin,zxcSImg,zxcNme,zxcHofF,zxcLast,zxcSec,zxcTO;
  13. var zxcFndCnt=0;
  14. var zxcAtpCnt=0;
  15. var zxcClickAry=[];
  16. var zxcRemAry=[];
  17. var zxcHofFAry=[];
  18. var zxcExp=new Date(new Date().getTime()+zxcDays*86400000).toGMTString();
  19.  
  20. function zxcMakePanel(){
  21.  zxcNme=document.getElementById('zxcName').value;
  22.  if (zxcNme.length<1){ zxcNme='No Name'; }
  23.  document.getElementById('zxcStart').value='ReStart the Game';
  24.  zxcSec=new Date().getTime();
  25. zxcTO=setInterval('zxcTimer()',1000);
  26.  var zxcpanel=document.getElementById('zxcImgPanel')
  27. zxcFnd=document.getElementById('zxcFound');
  28. zxcAtp=document.getElementById('zxcAttempts');
  29.  zxcTme=document.getElementById('zxcTime');
  30.  zxcMin=document.getElementById('zxcMinutes');
  31.  document.getElementById('zxcDisplay').style.visibility='visible';
  32. var zxcnuofimgs=document.getElementById('zxcNuofImgs');
  33. zxcnuofimgs.value=zxcnuofimgs.value.replace(/\D/g,'');
  34. var zxcnu=parseInt(zxcnuofimgs.value);
  35. if (zxcnuofimgs.value.length<1){ zxcnu=zxcUseAry.length; zxcnuofimgs.value=zxcnu; }
  36.  else if (zxcnu>1){ zxcnu=zxcnu/2; }
  37.  else { zxcnu=1; zxcnuofimgs.value=2; }
  38.  if (zxcnu>zxcUseAry.length){ zxcnu=zxcUseAry.length; }
  39.   zxcFndCnt=zxcnu*2;
  40.   zxcFnd.firstChild.data=zxcFndCnt;
  41.   zxcAtpCnt=0;
  42.   zxcAtp.firstChild.data=zxcAtpCnt;
  43.   var zxcnewary=[];
  44.   for (var zxc0=0;zxc0<zxcnu;zxc0++){
  45.   zxcnewary.push(zxcUseAry[zxc0]);
  46.  }
  47.  
Best wishes!
Mar 8 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Patricio Stegmann | last post by:
Hi, I am trying to develop a very basic but portable chat engine with php. I would like to develop it without any database or filesystem stuff, because I want it very portable and easy to install....
0
by: Tom Bates | last post by:
Can I include the same include files in global.asa that I use in other ..asp scripts? I haven't been able to make it work. My O'Reilly book says that global.asa can have includes, but the syntax...
5
by: Bill Sneddon | last post by:
Sorry if this is an easy question. Does Javascript work "out of the box with IIS" as an Active server page? ie. does it have the ability to open files ect.? I tried this command and it does...
8
by: DeadCert | last post by:
Hi, How can I store all my scripts on a separate page and then call them from the html page that I want to use them on? the <head> section is getting too cluttered and I would like to store all in...
7
by: ergobob | last post by:
Hello, I have two small PHP scripts running on a test page at: http://www.usernomics.com/ergonomic-products-accessories5.html Both scripts work perfectly when there is one script on a page....
1
by: Pete Mahoney | last post by:
Our company has just started the move from ASP to ASP.Net. We have just finished our first .Net projects, and are now in the process of deploying them. We use FrontPage at our company to allow...
45
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
17
by: John Salerno | last post by:
Ok, I've been browsing through the MySQLdb docs, and I *think* I know the kind of code I need to write (connect, cursor, manipulate data, commmit, etc. -- although I probably need to get more...
1
by: dcnicholls | last post by:
This is my first post to this forum: I use ASP occasionally but don't know a lot of it, and the Windows IIS was invented by MS to torture me :) So I'm not sure if this should be herre or on the IIS...
5
by: webmaster | last post by:
I am using two scripts (menus from milonic.com and a rotating news script we have used successfully for many years) on our website (www.imca-int.com) that independently work fine but together lead...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.