Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This should do what you're looking for:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http-//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Jose Cuervo PBV&lt;/title&gt; &lt;link href="rosters.css" rel="stylesheet" type="text/css" /&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;img src = "./images/Cuervo_Logo.jpg" alt = "Cuervo PBV Logo" /&gt; &lt;select id='standings' name='standings' onchange="listTeam(this)"&gt; &lt;option value='0'&gt;First Place&lt;/option&gt; &lt;option value='1'&gt;Second Place&lt;/option&gt; &lt;option value='2'&gt;Third Place&lt;/option&gt; &lt;option value='3'&gt;Fourth Place&lt;/option&gt; &lt;option value='4'&gt;Fifth Place&lt;/option&gt; &lt;/select&gt; &lt;select id='leaderBoard' name='leaderBoard' multiple="multiple" size="1" style="width: 300px;" &gt;&lt;/select&gt; &lt;script type="text/javascript"&gt; //put script block at end of body to ensure all other elements have already //been loaded into the DOM (and therefore exist when we need them to. // //"new Array" is not helpful here, so use literal notation instead. var teams = [ "Jenny Kropp Whitney Pavlik", "Jennifer Fopma Brooke Sweat", "Kristen Batt Raquel Ferreira", "Emily Day Heather Hughes", "Christal Engle Tealle Hunkus" ], listTeam = function listTeam(sel) { var val = document.getElementById('standings').value, //get the selected value team = teams[val], //get the selected team, based on value opt = document.createElement('option'), //create an &lt;option&gt; element lb = document.getElementById('leaderBoard'), //get the leaderBoard select element children = lb.children.length, //store the number of &lt;option&gt; child elements child = null, //declare a variable to store an &lt;option&gt; child element i = 0; //incrementor opt.innerText = team; //set the innerText for (i = 0; i &lt; children; i += 1) { //loop through every child element of leaderBoard child = lb.children[0]; //store reference to element lb.removeChild(child); //remove from leaderBoard } lb.appendChild(opt); //add new &lt;option&gt; element }; listTeam(); //call function on initial load as the leaderBoard select element has a selected child &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload