Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I attach links to individual array items?
    primarykey
    data
    text
    <p>I have been working for hours trying to get this to work. What I want to do is to: First, have two drop down menu, first one controlling the second. Then I want to be able to link each individual "second-selection" to a href. However, the "second-selections" are in an array and I do not know how to access them into html. Please help. </p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Any Title&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;script type="text/javascript"&gt; var firmwares = []; firmwares[1] = ["Sacramento","San Diego","San Francisco","Los Angeles"]; firmwares[2] = ["Cleveland","Akron","Canton","Cincinnati","Columbus"]; firmwares[3] = ["Philadelphia","Pittsburgh","Harrisburgh"]; firmwares[4] = []; function fillSelect(nValue,nList){ nList.options.length = 1; var curr = firmwares[nValue]; for (each in curr) { var nOption = document.createElement('option'); nOption.appendChild(document.createTextNode(curr[each])); nOption.setAttribute("value",curr[each]); nList.appendChild(nOption); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action=""&gt; &lt;div&gt; &lt;select name='phones' onchange="fillSelect(this.value,this.form['firmwares'])"&gt; &lt;option value=""&gt;Select Your State&lt;/option&gt; &lt;option value="1"&gt;California&lt;/option&gt; &lt;option value="2"&gt;Ohio&lt;/option&gt; &lt;option value="3"&gt;Pennsylvania&lt;/option&gt; &lt;option value="4"&gt;Alaska&lt;/option&gt; &lt;/select&gt; &lt;select name='firmwares' &gt; &lt;option value=""&gt;Select Your City&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/form&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.
 

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