Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Location
    Philly
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please help me with this code again sorry guys I just can't code JS :(

    Can you help me with this code it's for a class, but a graduate class. The codes connects to another and I will explain. The book is New Perspectives JavaScript and Ajax, 2nd Edition; the exercise is Tutorial 7 Case Problem #1 page 433-434 if you want to read along. The file french5.htm connects to engfr.js and they are supposed to link together so french5htm shows a list of English and French and there's functions to switch back and for on the site, but my following code is incorrect and I wanted to know if someone can help me; please look thanks!


    french5.htm (not code)

    <?xml version="1.0" encoding="UTF-8" ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <!--
    New Perspectives on JavaScript, 2nd Edition
    Tutorial 7
    Case Problem 1

    French Phrases
    Author: Franco Ferraiolo
    Date: 1/29/13

    Filename: french5.htm
    Supporting files: engfr.js, french.js, styles.css

    -->

    <title>French Phrases Week 5</title>
    <!-- links and functions for the site -->
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <link href="engfr.js" rel="javascript" type="text/js" />
    Var function.setUp
    function[i]=setUp
    Var link
    link.setUp=(link href="engfr.js" rel="javascript" type="text/js" /)
    Var transdoc
    transdoc.setUp="engfr.js"
    Var olElem
    olElem.setUp="JavaScript"
    Var newLI
    newLI.setUp=list.js+"text/js"

    <!-- functions for the site -->
    function setUp(link,transdoc,newLI,olElem)
    if (setUp.link)
    <link href="engfr.js" rel="javascript" type="text/js" />("setUp" + link,transdoc,newLI,olElem)
    else if (function.setUp)
    function.setUp(link,transdoc,newLI,olElem)
    <!-- swap function -->
    Var swapFE()
    Var pharse
    event.pharse
    swapFE.pharse.event=mousedown
    Var pharseNum
    event.pharseNum
    swapFE.pharseNum.event=selected
    events.pharse.pharseNum
    link.english(link href="engfr.js" rel="javascript" type="text/js" /"english"
    font.value.color=(155,102,102)
    function=swapFE.pharse.pharseNum
    function.swapFE(pharse.pharseNum)
    Var swapEF
    array[i]css.font.color=(#000000)
    swapEF=css.font.color=(#000000)
    </head>



    <body>
    <div id = "page">
    <div id="head">
    <div id = "rightHead">
    <b>Prof. Eve Granger</b><br />
    Office: 810 Linton Hall<br />
    Hours: TR: 3:00-4:30
    </div>
    <div id = "leftHead">
    <b>French 101</b><br />
    MWF: 9:00-9:50<br />
    Rm. 402 Linton Hall
    </div>
    </div>

    <ul id="links">
    <li class="newgroup"><a href="#">Home</a></li>
    <li class="newgroup"><a href="#">Phrases</a></li>
    <li><a href="#">Week 1 Phrases</a></li>
    <li><a href="#">Week 2 Phrases</a></li>
    <li><a href="#">Week 3 Phrases</a></li>
    <li><a href="#">Week 4 Phrases</a></li>
    <li><a href="#">Week 5 Phrases</a></li>
    <li class="newgroup"><a href="#">Quizzes</a></li>
    <li><a href="#">Chapter 1 Quiz</a></li>
    <li><a href="#">Chapter 2 Quiz</a></li>
    <li><a href="#">Chapter 3 Quiz</a></li>
    <li class="newgroup"><a href="#">Dept. of French</a></li>
    <li><a href="#">French 101</a></li>
    <li><a href="#">French 135</a></li>
    <li><a href="#">French 155</a></li>
    <li><a href="#">French 201</a></li>
    <li><a href="#">French 301</a></li>
    <li class="newgroup"><a href="#">Staff</a></li>
    <li><a href="#">Denise Abbot</a></li>
    <li><a href="#">Viola Devreaux</a></li>
    <li><a href="#">Eve Granger</a></li>
    <li><a href="#">Cynthia Trudeau</a></li>
    <li><a href="#">Gary Vironque</a></li>
    </ul>

    <div id = "doc">
    <h1>Week 5 Phrases</h1>
    <h2>Press down your mouse button on each phrase to translate</h2>

    </div>
    <address>
    French-English Translation Page
    </address>
    </div>

    </body>

    </html>

    connects to engfr.js (not code)



    /*
    New Perspectives on JavaScript, 2nd Edition
    Tutorial 7
    Case Problem 1

    Author: Franco Ferraiolo
    Date: 1/29/13

    Filename: engfr.js


    Function List:

    addEvent(object, evName, fnName, cap)
    Adds an event hander to object where evName is the name of the event,
    fnName is the function assigned to the event, and cap indicates whether
    event handler occurs during the capture phase (true) or bubbling
    phase (false)

    setUp()
    Insert the current week's french phrases into document and set up
    event handlers for the phrases.

    swapFE(phrase, pnum)
    Changes a French phrase to the English version of that phrase.

    swapEF(phrase, pnum)
    Changes an English phrase ot the Frech version of that phrase.

    */
    <link href="www.french5.htm" rel="notepad" type="text/htm" />
    function addEvent(object, evName, fnName, cap) {
    if (object.attachEvent)
    object.attachEvent("on" + evName, fnName);
    else if (object.addEventListener)
    object.addEventListener(evName, fnName, cap);
    }

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    Please use [ code ] and [ /code ] (without the spaces) to properly present (and indent) your code. You can easily do this by using the hash/octothorpe # symbol on top of the text area (not #i)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by devnull69 View Post
    Please use [ code ] and [ /code ] (without the spaces) to properly present (and indent) your code. You can easily do this by using the hash/octothorpe # symbol on top of the text area (not #i)
    You were asked to do this in your previous post.

    You say that the code does not work. In what respect? What error messages do you receive? Have you tried using your error console?

    Var swapFE()
    Var pharse
    .. and others
    Javascript is case sensitive. The var keyword is not capitalised. What is a pharse?

    Var function.setUp
    A function is not a variable.

    And many other errors.

    Why are you taking this graduate course in Javascript programming when by your own admission you are not good at it? I would say that you were all at sea.

    It is not really in your best interests that others do your all or most homework for you. Many people would regard that as cheating. Furthermore your teacher may gain a false and exaggerated idea of your programming capabilities and so not offer you the support you need. Also, if you hand in other people's work which you do not completely understand, then you will start to fall behind and your difficulties will increase.

    Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose. You can (and should) edit it to make it more meaningful.
    Last edited by Philip M; 01-30-2013 at 08:14 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Quote Originally Posted by Philip M View Post
    I would say that you were all at sea.
    Philip, I know you are an understated person.

    But that one has to be the grandest understatement you've made.

    At sea, without a boat, without a life jacket, with cement boots, with...

    I know it's mean to make comments like this, but WOW! A *graduate* course? And he is on "Tutorial 7"? What in the world did his work for Tutorials 1 through 6 look like?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •