473,387 Members | 1,724 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,387 software developers and data experts.

Javascript in Head doesn't process

5
I have a feeling there's some really stupid something I'm doing but for some reason that I can't find at all, the JavaScript in my head tag won't process on one of my pages. Any help will be greatly appreciated while I try to figure it out.

http://webdrive.service.emory.edu/users/jarnol4/public/cc/webprototype/viewer.htm
Apr 14 '07 #1
4 1452
ace214
5
Ok, so it's not that's in the head, because I've moved it and a my button rollover script to separate scripts in an attempt to isolate the problem. So the it's the my picture changing script that is the problem:
Here is the script
Here is the page

Thanks for any help.....
Apr 14 '07 #2
hi pal,
there where a lot of syntax errors :P

but i have changed some code

document.getElementById("Caption").innerHTML = Captions[i];
instead of
document.getElementById("Caption").childNodes[0].nodeValue = Captions[i];

REMOVED:
if (img != "htm") { //If an img number is passed
i = img; //Set i to img for next/prev counter
startingPic = "pics/".concat(i,".jpg"); //Set startingPic for loading in body of page
}
else //If no img number is passed (i.e. somone types url)
startingPic = "pics/000.jpg"; //Start at pic 0, i is already at 0
*********************
ADDED:
function firstpicture(){
if (document.getElementById("Picture")==null){
setTimeout('firstpicture()',1000);
}
else{
document.getElementById("Picture").src='pics/000.jpg';
}
}
setTimeout('firstpicture()',1000);

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
  2. <html><head>
  3. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Emory University Concert Choir: Pictures</title>
  4. <script type="text/javascript" src="buttonbar.js"></script>
  5. <script type="text/javascript" src="viewer.js"></script>
  6. <style type="text/css">
  7. h1 {color: rgb(51,51,102); font-family: "Verdana"; font-size: 150%; text-align: center}         /* Heading */
  8. p.footer {color: rgb(51,51,102); font-family: "Verdana"; font-size: 80%; text-align: center} /* Footer */
  9. a {color: rgb(51,51,102)}                                                                     /* Supress Link Colors */
  10. td.button {width: 16%}                                                                         /* Button Bar Cells */
  11. img {border: 0px; display: block; margin-left:auto; margin-right:auto;}                                                                         /* No image borders */
  12. </style>
  13. <script>
  14.   url = window.location.toString(); //Get URL
  15. img = url.substr(url.length - 3); //Get last 3 characters of URL
  16.  
  17. Captions = new Array();
  18. Captions[0]= "Photo 1 of 25";
  19. Captions[1]= "Photo 2 of 25";
  20. Captions[2]= "Photo 3 of 25";
  21. Captions[3]= "Photo 4 of 25";
  22. Captions[4]= "Photo 5 of 25";
  23. Captions[5]= "Photo 6 of 25";
  24. Captions[6]= "Photo 7 of 25";
  25. Captions[7]= "Photo 8 of 25";
  26. Captions[8]= "Photo 9 of 25";
  27. Captions[9]= "Photo 10 of 25";
  28. Captions[10]= "Photo 11 of 25";
  29. Captions[11]= "Photo 12 of 25";
  30. Captions[12]= "Photo 13 of 25";
  31. Captions[13]= "Photo 14 of 25";
  32. Captions[14]= "Photo 15 of 25";
  33. Captions[15]= "Photo 16 of 25";
  34. Captions[16]= "Photo 17 of 25";
  35. Captions[17]= "Photo 18 of 25";
  36. Captions[18]= "Photo 19 of 25";
  37. Captions[19]= "Photo 20 of 25";
  38. Captions[20]= "Photo 21 of 25";
  39. Captions[21]= "Photo 22 of 25";
  40. Captions[22]= "Photo 23 of 25";
  41. Captions[23]= "Photo 24 of 25";
  42. Captions[24]= "Photo 25 of 25";
  43.  
  44. var i = 0;                          //Setup i
  45. last = 24;                      //Last pic for easy looping
  46. function firstpicture(){
  47. if (document.getElementById("Picture")==null){
  48. setTimeout('firstpicture()',1000);
  49. }
  50. else{
  51. document.getElementById("Picture").src='pics/000.jpg';
  52. }
  53. setTimeout('firstpicture()',1000);
  54. function nextPic() { //Next Picture
  55.     if (i == last) {         //Loop back to beginning if on last picture
  56.         i = 0;
  57.         newPic = "pics/000.jpg";
  58.     }
  59.     else {                 //Otherwise, increase to next picture
  60.         i++;
  61.         if (i < 10)             //Filename workaround
  62.             newPic = ("pics/00").concat(i,".jpg");
  63.         else
  64.             newPic = ("pics/0").concat(i,".jpg");
  65.     }
  66.  
  67.     document.getElementById("Picture").src = newPic;
  68.     document.getElementById("Caption").innerHTML = Captions[i];
  69. }
  70.  
  71. function prevPic() { //Previous Picture
  72.     if (i == 0) {             //Loop back to end if on first picture
  73.         i = last;
  74.         newPic = ("pics/0").concat(i,".jpg");
  75.     }
  76.     else {                 //Otherwise, go back to previous picture
  77.         i--;
  78.  
  79.         if (i < 10)             //Filename workaround
  80.             newPic = ("pics/00").concat(i,".jpg");
  81.         else
  82.             newPic = ("pics/0").concat(i,".jpg");
  83.     }
  84.  
  85.     document.getElementById("Picture").src = newPic;
  86.     document.getElementById("Caption").innerHTML = Captions[i];
  87. }
  88.  
  89. function firstPic() { //First Picture
  90.     if (i != 0) {
  91.         i = 0;
  92.         newPic = "pics/000.jpg";
  93.         document.getElementById("Picture").src = newPic;
  94.         document.getElementById("Caption").innerHTML = Captions[i];
  95.     }
  96. }
  97.  
  98. function lastPic() { //Last Picture
  99.     if (i != last) {
  100.         i = last;
  101.         newPic = ("pics/0").concat(i,".jpg");
  102.         document.getElementById("Picture").src = newPic;
  103.     document.getElementById("Caption").innerHTML= Captions[i];
  104.     }
  105. }
  106.  
  107. </script>
  108. </head>
  109. <body style="color: rgb(0, 0, 0); background-color: rgb(51, 51, 102); margin: 0px">
  110. <table style="background-color: rgb(221, 214, 198); text-align: left; margin-left: auto; margin-right: auto; width: 750px;" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td>
  111. <a href="index.htm"><img alt="" src="logo.gif"></a></td></tr><tr><td>
  112. <table style="background-color: rgb(51, 51, 102); width: 750px; text-align: center; vertical-align: middle; margin-left: auto; margin-right: auto;" border="0" cellpadding="0" cellspacing="0"><tbody><tr>
  113. <td class="button"><a href="choir.htm" onmouseover="light('Choir')" onmouseout="unlight('Choir')"><img name="Choir" alt="" src="Choir_unlit.gif"></a></td>
  114. <td class="button"><a href="director.htm" onmouseover="light('Director')" onmouseout="unlight('Director')"><img name="Director" alt="" src="Director_unlit.gif"></a></td>
  115. <td class="button"><a href="concerts.htm" onmouseover="light('Concerts')" onmouseout="unlight('Concerts')"><img name="Concerts" alt="" src="Concerts_unlit.gif"></a></td>
  116. <td class="button"><a href="auditions.htm" onmouseover="light('Auditions')" onmouseout="unlight('Auditions')"><img name="Auditions" alt="" src="Auditions_unlit.gif"></a></td>
  117. <td class="button"><a href="audio.htm" onmouseover="light('Audio')" onmouseout="unlight('Audio')"><img name="Audio" alt="" src="Audio_unlit.gif"></a></td>
  118. <td class="button"><a href="pictures.htm"><img name="Pictures" alt="" src="Pictures_lit.gif"></a></td></tr></tbody></table></td></tr></tbody></table>
  119. <table style="background-color: rgb(221, 214, 198); width: 750px; text-align: center; margin-left: auto; margin-right: auto;" border="0" cellpadding="4" cellspacing="0"><tbody><tr><td><br>
  120. <table style="color: rgb(51,51,102); font-family: Verdana; font-size: 90%; text-align: center; margin-left: auto; margin-right: auto; width: 742px" border="0" cellpadding="4" cellspacing="0"><tbody><tr>
  121. <td style="width: 25%"><a href="javascript:firstPic()">First</a> <a href="javascript:prevPic()">Previous</a></td>
  122. <td style="width: 50%"><a href="pictures.htm">Back to Album</a></td>
  123. <td style="width: 25%"><a href="javascript:nextPic()">Next</a> <a href="javascript:lastPic()">Last</a></td></tr></tbody></table><br>
  124. <a href="javascript:nextPic()"><img id="Picture" alt="Picture"></a>
  125.  
  126. <div id="Caption" style="color: rgb(51,51,102); font-family: Verdana; font-size: 90%; text-align: center">Photo 1 of 25</div>
  127.  
  128. <br><hr style="width: 100%; height: 2px;"><p class="footer"><a href="http://www.emory.edu/COLLEGE">Emory College</a> | <a href="http://www.emory.edu">Emory University</a> | <a href="http://www.emory.edu/ARTS">Arts at Emory</a> | <a href="http://www.music.emory.edu/">Emory Music Department</a>
  129. </td></tr>
  130. </tbody></table>
  131. </body></html>
  132.  
Well i HTH
It´s not easy to adjust an integrated script.
let me know
ps did u wrote it yourself?
peace
Apr 14 '07 #3
drhowarddrfine
7,435 Expert 4TB
Your image has no source.
Apr 14 '07 #4
ace214
5
I adjusted the script anyway. It must have been some error. Yes, I'm writing it from scratch. Sorry for the late response- didn't get the subscribe email. Thanks for your help.
Apr 17 '07 #5

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

Similar topics

4
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users...
5
by: mouac01 | last post by:
I'm new to PHP/Javascript. I have a simple form I want to validate the fields with javascript and then run the PHP script. All the scripts are in one page. I want PHP to control where the next...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
9
by: Boris Yeltsin | last post by:
I use Master Pages, so I make use of URL rebasing through the ~ operator, like this in the <head>: <link runat="server" href="~/Root.master.css" media="screen" rel="stylesheet" type="text/css" />...
8
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :)...
9
by: Erwin Moller | last post by:
Hi, Can anybody comment on this? In comp.lang.php I advised somebody to skip using: <script language="javascript"> and use: <script type="text/javascript"> And mr. Dunlop gave this response:
22
by: Christopher Nelson | last post by:
I have a little menu system which essentially takes HTML like: <div id='foo'></div> and retrieves foo.shtml from the server and inserts it inside the <div>. But sometimes I'd like foo.shtml...
1
by: KRISHNA PRAVI | last post by:
the error is "runtime error object expected" here is the code....................................................................................... <script language="javascript"...
3
by: jackson.rayne | last post by:
Hello, Another newbie question here. Let me explain my situation first. I have bought a 3rd party tool that runs a PHP script and gives me some HTML code which I can directly use in my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.