Solved

Debug Javascript

Posted on 2012-03-13
4
251 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
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 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

820 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