Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 578411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:15:26+00:00 2026-05-13T14:15:26+00:00

How do I get the phrase number from the phrase object using the parseInt()

  • 0

How do I get the phrase number from the phrase object using the parseInt() function? I tried to create the function within the swapFE function in var phrasenum below but it did not work. I think my values are wrong. What should I put there instead? Any help would be greatly appreciated. Thanks in advance! The following is the french phrase number (1-10 or in JavaScript 0-9) and the french an english phrases to be used:

> var english=new Array();
english[0]="This hotel isn't far from the Eiffel Tower.";
english[1]="What time does the train arrive?";
english[2]="We have been waiting for the bus for one half-hour.";
english[3]="This meal is delicious";
english[4]="What day is she going to arrive?";
english[5]="We have eleven minutes before the train leaves!";
english[6]="Living in a foreign country is a good experience.";
english[7]="Excuse me! I'm late!";
english[8]="Is this taxi free?";
english[9]="Be careful when you go down the steps.";

var french=new Array();
french[0]="Cet hôtel n'est pas loin de la Tour Eiffel.";
french[1]="A quelle heure arrive le train?";
french[2]="Nous attendons l'autobus depuis une demi-heure.";
french[3]="Ce repas est délicieux";
french[4]="Quel jour va-t-elle arriver?";
french[5]="Nous avons onze minutes avant le départ du train!";
french[6]="Habiter dans un pays étranger est une bonne expérience.";
french[7]="Excusez-moi! Je suis en retard!";
french[8]="Est-ce que ce taxi est libre?";
french[9]="Faites attention quand vous descendez l'escalier.";

Here are the functions I am working on:

function setUpTranslation() {
   var phrases = document.getElementsByTagName("p");

   for (i = 0; i<phrases.length; i++) {
      phrases[i].number = i;
      phrases[i].childNodes[1].innerHTML = french[i];

      phrases[i].childNodes[1].onmousedown = function() { swapFE(event); }; 
  }

}

function swapFE(e) {
       var phrase = e.srcElement; 

       var phrasenum = parseInt(phrase[1].childNodes[1].innerText);

       alert("French Number = "+phrasenum+"Phrase = "+phrase.childNodes[1]);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:15:27+00:00Added an answer on May 13, 2026 at 2:15 pm

    This is the answer I came up with and it worked. See var phrasenum. Thanks for all your help guys!

    //this function changes the French phrase to an English phrase.
        function swapFE(e) {
               var phrase = e.srcElement; 
               //phrase.innerText = english[phrase.id];
               var parent = phrase.parentNode;
               //childNodes[0] is the number of the phrase +1 
               var idnum = parent.childNodes[0];
               //parseInt takes a textstring and extracts it to make a number. Then you will subtract 1 from the number.
               var phrasenum = parseInt(idnum.innerHTML)-1;
               phrase.innerText = english[phrasenum];
    
    
      }
    
    
    function swapEF(e) {
           var phrase = e.srcElement; 
           //phrase.innerText = english[phrase.id];
           var parent = phrase.parentNode;
           var idnum = parent.childNodes[0];
           var phrasenum = parseInt(idnum.innerHTML)-1;
           phrase.innerText = french[phrasenum];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 373k
  • Answers 373k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have a document that fits screen height and is wider… May 14, 2026 at 7:37 pm
  • Editorial Team
    Editorial Team added an answer It was a scope issue. After reading this post, I… May 14, 2026 at 7:37 pm
  • Editorial Team
    Editorial Team added an answer The AdditionalPageHead Delegate Control should be on every out-of-the-box master… May 14, 2026 at 7:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.