?
Solved

Debug Javascript

Posted on 2012-03-13
4
Medium Priority
?
258 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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 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