Menu

[solved]-Write Javascript Function Populating Dropdown Menu Html Football Player Information Page L Q39011675

Write a javascript function for populating the dropdown menu inhtml

Football Player Information Page
       loadPlayersPage method:
           parameters:none

           purpose: Thismethod will populate the dropdown menu to allow the
                  user to select which player’sinformation to view.

                  To handle this, you will needto iterate through the players array
                  and do the following for eachplayer:
                      1. Createan anchor tag
                      2. Set thehref to “#”, this will make sure the
                         anchor tag doesn’t change pages
                      3. Set theonclick to call switchPlayers method
                         (this will need to pass in the index inside theplayers array)
                      4. Set theanchor tag’s text to the player’s name.

                  After setting all of theanchor tags, update the innerHTML of the dropdown menu.
                  As a note, the id for thedropdown menu is player_selector.

The problem above is based on

/*
   players is an array to hold each player’sinformation.
   Fields:
       name – Football player’s name
       img – The relative/absolute path tothe image file.
       alt – The alternative text thatdescribes the image.
       year – The student’s year incollege (Freshman, Sophomore, Junior, Senior).
       major- The student’s currentcollege major.
       games_played – The number offootball games the student has played for the Buffs.
       pass_yards – The total number ofpassing yards in the student’s football career for the Buffs.
       rushing_yards – The total number ofrushing yards in the student’s football career for the Buffs.
       receiving_yards – The total numberof receiving yards in the student’s football career for theBuffs.
*/
var players = [{name:”John Doe”, img:”../resources/img/player1.jpg”, alt:”Image of Player 1″,year:”Sophomore”, major:”Art”, games_played: 23, pass_yards: 435,rushing_yards: 200, receiving_yards: 88},
              {name:”James Smith”, img:”../resources/img/player2.jpg”, alt:”Image of Player 2″,year:”Junior”, major:”Science”, games_played: 17, pass_yards: 192,rushing_yards: 102, receiving_yards: 344},
              {name:”Samuel Phillips”, img:”../resources/img/player3.jpg”, alt:”Image of Player 3″,year:”Freshman”, major:”Math”, games_played: 8, pass_yards: 35,rushing_yards: 70, receiving_yards: 98},
              {name:”Robert Myers”, img:”../resources/img/player4.jpg”, alt:”Image of Player 4″,year:”Senior”, major:”Computer Science”, games_played: 31,pass_yards: 802, rushing_yards: 375, receiving_yards: 128}];

Expert Answer


Answer to Write a javascript function for populating the dropdown menu in html Football Player Information Page loadPlayersPage me… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *