473,324 Members | 2,531 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,324 software developers and data experts.

Tutorial 4 Case 2

Hi

My moveIt function is not working anmd I do not know why, can anyone help me

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <!-- 
  4.    New Perspectives on JavaScript
  5.    Tutorial 4
  6.    Case Problem 2
  7.  
  8.    The Chamberlain Civic Center
  9.    Author: Jodie St. John 
  10.    Date:   March 4, 2009
  11.  
  12.    Filename:         ccc.htm
  13.    Supporting files: back.jpg, ccc.gif, ccc.js, styles.css
  14. -->
  15. <title>This Month at the Chamberlain Civic Center</title>
  16. <link href="styles.css" rel="stylesheet" type="text/css" />
  17. <script  type="text/javascript" src="ccc.js"></script>
  18. <script type="text/javascript">
  19.     function Marquee() {
  20.       t1 = setInterval("moveIt('Text1')", 130);
  21.       t2 = setInterval("moveIt('Text2')", 130);
  22.       t3 = setInterval("moveIt('Text3')", 130);
  23.       t4 = setInterval("moveIt('Text4')", 130);
  24.       t5 = setInterval("moveIt('Text5')", 130);  
  25.       t6 = setInterval("moveIt('Text6')", 130);
  26.     } 
  27.  
  28.     function Stop() {
  29.       alert ("stopping");
  30.  
  31.       clearInterval(t1);
  32.       clearInterval(t2);
  33.       clearInterval(t3);
  34.       clearInterval(t4);
  35.       clearInterval(t5);
  36.       clearInterval(t6);
  37.  
  38.       alert("Stop");
  39.  
  40.     }
  41.  
  42.     function moveIt(id) {
  43.         alert("inside moveIt");
  44.         var y = yCoord(id);
  45.        // alert("hi");
  46.         if(y < -100) {
  47.           placeIt(id, 5, 750);
  48.         }
  49.         else {
  50.           shiftIt(id, 0, -5);}
  51.     }
  52.  
  53.  
  54.  
  55. </script>
  56. </head>
  57.  
  58. <body>
  59. <form id="marquee_buttons" action="">
  60.  
  61. <div id="panel">
  62.    <p>
  63.       <img src="ccc.gif" alt="The Chamberlain Civic Center" />
  64.    </p>
  65.    <h2>
  66.       Events This Month
  67.    </h2>
  68.    <p>To order tickets: Call the box office at (971) 555-9191<br />
  69.    Or click <a href="#">here</a> to order online.
  70.    </p>
  71. </div>
  72.  
  73. <div id="BOX">
  74.  
  75.    <div id="Text1" style="position: absolute; left: 0px; top:5px">
  76.      Coming Soon to the CCC
  77.    </div>
  78.  
  79.    <div id="Text2" style="position: absolute; left: 0px; top: 50px">
  80.      <b>October 2nd, 8 p.m.<br />
  81.      Falstaff</b><hr />
  82.      Enjoy the music of Verdi's <i>Falstaff</i>, as presented by the 
  83.      popular Rockie Mountain Opera Company. Seating is limited.<br /><br />
  84.      Tickets:  Box ($55), Main Floor ($45), Balcony ($35)
  85.    </div>
  86.  
  87.    <div id="Text3" style="position: absolute; left: 0px; top: 200px">
  88.      <b>October 7th, 8 p.m.<br />
  89.      Taiwan Acrobats</b><hr />
  90.      The Taiwan Acrobats return to the Carson Civic Center for another 
  91.      evening of fun and excitment.<br /><br />
  92.      Tickets:  Box ($40), Main Floor ($35), Balcony ($30)
  93.    </div>
  94.  
  95.    <div id="Text4" style="position: absolute; left: 0px; top: 350px">
  96.      <b>October 14th, 8 &amp; 10 p.m.<br />
  97.      Roy Taylor</b><hr />
  98.      Enjoy of the blues sound of the legendary "Slow Train" Taylor. 
  99.      Two performances at 8 and 10 p.m.<br /><br />
  100.      Tickets:  Box ($40), Main Floor ($35), Balcony ($30)
  101.    </div>
  102.  
  103.    <div id="Text5" style="position: absolute; left: 0px; top: 500px">
  104.      <b>October 21st, 8 p.m.<br />
  105.      Celtic Dancers</b><hr />
  106.      Enjoy an evening of Celtic music and dance, as presented by the
  107.      Oban Dance Company of Scotland.<br /><br />
  108.      Tickets:  Box ($30), Main Floor ($25), Balcony ($20)
  109.    </div>
  110.  
  111.    <div id="Text6" style="position: absolute; left: 0px; top: 650px">
  112.      <b>October 28th, 8 p.m.<br />
  113.      An Evening with Ike</b><hr />
  114.      David Lee presents <i>An Evening with Ike</i>, his acclaimed one-man
  115.      show of the life and times of Dwight Eisenhower.<br /><br />
  116.      Tickets:  Box ($35), Main Floor ($30), Balcony ($25)
  117.    </div>
  118. </div>
  119.  
  120. <div id="form_buttons">
  121.       <input type="button" value="Scroll Marquee" onclick="Marquee()" />
  122.       <input type="button" value="Stop  Marquee" onclick="Stop()"/>
  123.       <input type="button" value="Reset" onclick="location.reload()" />
  124. </div>
  125.  
  126. </form>
  127. </body>
  128.  
  129. </html>
Mar 8 '09 #1
9 8059
RamananKalirajan
608 512MB
Hi, the file is working, can u pls attach the js file associated with it.. because its trowing error cant find the object placeIt and shiftIt... The function moveIt() is called and the alert is working.. can u pls bit more elaborate on your requirement.

Regards
Ramanan Kalirajan
Mar 9 '09 #2
This is the code for the java script file
Expand|Select|Wrap|Line Numbers
  1. /* 
  2.    New Perspectives on JavaScript
  3.    Tutorial 4
  4.    Case Problem 2
  5.  
  6.    The Chamberlain Civic Center
  7.    Name: Jodie St. John
  8.    Date: March 4, 2009
  9.  
  10.    Function List:
  11.    placeIt(id, x, y)
  12.       Places the id object at the page coordinates (x,y)
  13.  
  14.    shiftIt(id, dx, dy)
  15.       Shifts the id object dx pixels to the left and dy pixels down
  16.  
  17.    yCoord(id)
  18.       Returns the y-coordinate of the id object
  19. */
  20.  
  21.  
  22.  
  23. function placeIt(id, x, y) {
  24.   object = document.getElementById(id);
  25.   object.style.left=x+"px";
  26.   object.style.top=y+"px";
  27.  
  28. }
  29.  
  30. function shiftIt(id, dx, dy) {
  31.   object = document.getElementById(id);
  32.   object.style.left= yCoord(id)+dx+"px";
  33.   object.style.top = yCoord(id)+dy+"px";
  34. }
  35.  
  36. function yCoord(id) {
  37.   object=document.getElementById(id);
  38.   yc = parseInt(object.style.top);
  39.   return yc;
  40.  
  41. }
Mar 9 '09 #3
RamananKalirajan
608 512MB
Yupe... :-( I have tested your code on both Mozilla and IE (6) it seems to be working good.. Can u pls tell me what is the error you are getting in ur browser...

Regards
Ramanan Kalirajan
Mar 10 '09 #4
Hi

The code is suppose to move vertical up the page and it does not do that
Mar 10 '09 #5
Dormilich
8,658 Expert Mod 8TB
works for me (FF 3.0.7, Mac OS 10.5.6), although the CSS could need some improvement (got overlapping text)
Mar 10 '09 #6
RamananKalirajan
608 512MB
The code is working and the marquee effect what u had given is working from right to left diagonal wise.. Its not working in Vertical direction but works in a diagonal manner....

Regards
Ramanan Kalirajan
Mar 10 '09 #7
acoder
16,027 Expert Mod 8TB
The problem will most likely be (though I've only looked at and not tested your code) that you need an xCoord function:
Expand|Select|Wrap|Line Numbers
  1. function xCoord(id) {
  2.   var object=document.getElementById(id);
  3.   var xc = parseInt(object.style.left);
  4.   return xc;
  5. }
which you need to use in place of yCoord for style.left in ShiftIt().
Mar 10 '09 #8
did anyone get this to work? I am having the same problem, its not scrolling and i cant figure this xcord out.
Expand|Select|Wrap|Line Numbers
  1. function xCoord(id) { 
  2.   var object=document.getElementById(id); 
  3.   var xc = parseInt(object.style.left); 
  4.   return xc; 
  5.  
Aug 13 '09 #9
Fewtam
1
The solution was very simple; you just need to remove a line from your shiftIt() function so it reads:

Expand|Select|Wrap|Line Numbers
  1.         function shiftIt(id, dx, dy) {
  2.                  object = document.getElementById(id);
  3.                  object.style.top = yCoord(id)+dy+"px";
  4.         }
The problem was that the second yCoord line was creating two scrolling points on the y-axis, therefore it was scrolling diagonally. So take it out and it will only scroll vertically.
Feb 18 '10 #10

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

Similar topics

7
by: Alf P. Steinbach | last post by:
I have to shop Christmas gifts (and clean up... ;-)) before leaving on Christmas holiday tomorrow, where I'll effectively be without a network connection until January 6th, so I just posted what I...
7
by: Alf P. Steinbach | last post by:
The fourth part of my attempted Correct C++ tutorial is now available, although for now only in Word format (use free Open Office if no Word), and also, it's not yet been reviewed at all -- ...
15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
11
by: Sathyaish | last post by:
I had recieved an email sometime ago wherein I was asked to write a function that parsed a given string for the longest pallindrome it contained and replaced the pallindrome with another string,...
18
by: Xah Lee | last post by:
i've started to read python tutorial recently. http://python.org/doc/2.3.4/tut/tut.html Here are some quick critique: quick example: If the input string is too long, they don't truncate it,...
11
by: Magnus Lycka | last post by:
While the official Python Tutorial has served its purpose well, keeping it up to date is hardly anyones top priority, and there are others who passionately create really good Python tutorials on...
7
by: Turbo | last post by:
I have a written a detailed html tutorial here:- http://sandy007smarty.seo.iitm.ac.in/2006/09/26/html-tutorial/ I know there are a couple of html tutorials out there. But its a tutorial without...
31
by: Antoon Pardon | last post by:
The following is part of the explanation on slices in the tutorial: The best way to remember how slices work is to think of the indices as pointing between characters, with the left edge of the...
2
Banfa
by: Banfa | last post by:
Posted by Banfa The previous tutorial discussed what programming is, what we are trying to achieve, the answer being a list of instructions constituting a valid program. Now we will discuss how...
0
Curtis Rutland
by: Curtis Rutland | last post by:
Have any of you ever used a Reverse Polish Notation calculator? I did in high school. It was easily the best calculator ever (the HP=32SII). RPN is great, because you don't have to use parenthesis....
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...
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)...
1
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...
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.