This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes code to switch english to french and french to english Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "code to switch english to french and french to english" Watch "code to switch english to french and french to english" New topic
Author

code to switch english to french and french to english

Tesla Doty
Greenhorn

Joined: Apr 02, 2014
Posts: 9

I am new to Javascript and have this code to switch english to french and french to english. I have seen other posts on this same coding assignment and have tried to implement the answers from those problems into my code as well as what we went over in the chapter. Everything seems fine when I look at the code but the page isn't working as I intended so I know there is a problem. This is my first javascript assignment and I'm having a very difficult time locating my error. I appreciate any help in advance! I do not just want someone to code this for me, I want to understand where my error is. Here is the javascript code:




Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Tesla Doty wrote:Everything seems fine when I look at the code but the page isn't working as I intended so I know there is a problem.

Can you elaborate on what "not working" means? Is there an error in the JavaScript console. Does it do anything?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Tesla Doty
Greenhorn

Joined: Apr 02, 2014
Posts: 9

Jeanne Boyarsky wrote:
Tesla Doty wrote:Everything seems fine when I look at the code but the page isn't working as I intended so I know there is a problem.

Can you elaborate on what "not working" means? Is there an error in the JavaScript console. Does it do anything?


When I load the page there are English phrases. When you click the phrase it is supposed to show the english phrase, and on mouse up revert back. My apologies for not being as descriptive as I should be. Still getting the hang of wording forum questions right.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Open the JavaScript console. Are there any erros when you try to do things?

If not, set breakpoints and see what the code is doing.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Bear Bibeault wrote:Open the JavaScript console. Are there any erros when you try to do things?

If not, set breakpoints and see what the code is doing.


I think you might be assuming too much here, Bear.


GenRocket - Experts at Building Test Data
Tesla Doty
Greenhorn

Joined: Apr 02, 2014
Posts: 9

I am doing this for my html class. We have not got into setting breakpoints, debugging, or using the console. We have only just covered tidbits of javascript within web pages in tutorials. I feel like a total noob for not understanding this. The class just throws code at us and doesn't explain much about actually working with the code.
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

When I was tasked with writing an introduction to JavaScript in as few pages as possible I started with how to access the developer console, seemed the quickest way to get going.

Tesla, if you're using IE or Chrome: hit F12. If you're using Firefox: hold down Ctrl+Shift and then hit K. Look for where it says 'Console' and select that tab if it's not already selected. Are there any error messages (they'll likely be coloured red or orange)?

For starters, I would investigate this line:


It looks like you're trying to attach a file to the onload event handler. This won't work, the thing on the right of the = needs to be a function. I suspect it's supposed to be:


Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Rob Crowther wrote:When I was tasked with writing an introduction to JavaScript in as few pages as possible I started with how to access the developer console, seemed the quickest way to get going.


100% agree.

Learning how to use the console as a tool is one of the very first things to learn. Otherwise, you're flying blind. It's like trying to fight a training droid with the blast shield down -- unless you program using The Force.

Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

Can we expect "jQuery Jedi Masters" to follow "Secrets of the JavaScript Ninja"? ;)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Jedi Master === Ninja in Space!

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

(Although Secrets of the jQuery Jedi has a certain ring to it, I'm not sure I'd want to pay Lucas-level royalties!)
Tesla Doty
Greenhorn

Joined: Apr 02, 2014
Posts: 9

Rob Crowther wrote:When I was tasked with writing an introduction to JavaScript in as few pages as possible I started with how to access the developer console, seemed the quickest way to get going.

Tesla, if you're using IE or Chrome: hit F12. If you're using Firefox: hold down Ctrl+Shift and then hit K. Look for where it says 'Console' and select that tab if it's not already selected. Are there any error messages (they'll likely be coloured red or orange)?

For starters, I would investigate this line:


It looks like you're trying to attach a file to the onload event handler. This won't work, the thing on the right of the = needs to be a function. I suspect it's supposed to be:


Thank you so much for your help! Now I'll be able to figure out where my problems are. I can't believe they didn't tell us about that in class.
 
 
subject: code to switch english to french and french to english
 
Similar Threads
How to pass a javascript variable on a jsp to a servlet
Using Up/Down Arrow Key to Move in a table
Page section does not update after call of a4j:support in IE 9
need to create tree structure (parent node child node)
Google use Javascript or ajax on first page?