Note that there are some explanatory texts on larger screens.

plurals
  1. POget value from <select> and write output
    text
    copied!<p>I want to use the value from 'standings' to determine what is printed out in 'leaderboard' I can't seem to figure out where I am going wrong. I think this is the closest I have come to getting it to work. How can I pass the local variable team from inside the function to 'leaderboard'?</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;script type="text/javascript"&gt; var teams = new array(5); teams[0] = "Jenny Kropp Whitney Pavlik"; teams[1] = "Jennifer Fopma Brooke Sweat"; teams[2] = "Kristen Batt Raquel Ferreira"; teams[3] = "Emily Day Heather Hughes"; teams[4] = "Christal Engle Tealle Hunkus"; function listTeam(sel) { var i = document.getElementById('standings').value; var team = teams[i]; } &lt;/script&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;option&gt; &lt;script type="text/javascript"&gt; document.write(team); &lt;/script&gt; &lt;/option&gt; &lt;/select&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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