Solved

Debug Javascript

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now