Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Debug Javascript

Posted on 2012-03-13
4
Medium Priority
?
261 Views
Last Modified: 2012-03-24
I have a button that I want to move from the left to the right side when clicked. I am copying the code directly out of the book and it won't work. Maybe I missed something, but I can't see where. The page can be viewed here:

http://domgarofalo.com/ch_9_assess.html

Any help is appreciated.
0
Comment
Question by:Break40
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Author Comment

by:Break40
ID: 37716909
Please let me know what you find.
0
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 37717079
In firebug it says switch_sides is not defined
0
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 37718471
please paste the ch_9_assess.js code??
0
 
LVL 1

Accepted Solution

by:
slightlyoff earned 2000 total points
ID: 37720371
i don't see switch_sides() in your js code.

So onclick is calling a function that doesn't exsist.

<input type="button" value="Change Sides" id="change_sides" onclick="switch_sides();" />

your js is:

var the_button = document.getElementById("change_sides"); //DOM switches sides of the button on click, but not working!
the_button.onclick = function() {
  document.dir = (document.dir!="ltr") ? "ltr" : "rtl";
}

Open in new window


Try putting that inside:
function switch_sides(){
var the_button = document.getElementById("change_sides"); //DOM switches sides of the button on click, but not working!
the_button.onclick = function() {
  document.dir = (document.dir!="ltr") ? "ltr" : "rtl";
}
}

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question