Solved

Debug Javascript

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Web Development 6 68
Geolocation works...sometimes 2 37
Form submit takes only for one form 23 51
Checkbox changes display when resizing window 8 26
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
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…

732 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