Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Neither the <a href="http://www.w3schools.com/jsref/event_onselect.asp" rel="noreferrer"><code>onSelect()</code></a> nor <a href="http://www.w3schools.com/jsref/event_onclick.asp" rel="noreferrer"><code>onClick()</code></a> events are supported by the <code>&lt;option&gt;</code> tag. The former refers to selecting text (i.e. by clicking + dragging across a text field) so can only be used with the <code>&lt;text&gt;</code> and <code>&lt;textarea&gt;</code> tags. The <code>onClick()</code> event can be used with <code>&lt;select&gt;</code> tags - however, you probably are looking for functionality where it would be best to use the <a href="http://www.w3schools.com/jsref/event_onchange.asp" rel="noreferrer"><code>onChange()</code></a> event, not <code>onClick()</code>.</p> <p>Furthermore, by the look of your <code>&lt;c:...&gt;</code> tags, you are also trying to use <a href="http://java.sun.com/products/jsp/" rel="noreferrer">JSP</a> syntax in a plain HTML document. That's just... incorrect.</p> <p>In response to your comment to this answer - I can barely understand it. However, it sounds like what you want to do is get the value of the <code>&lt;option&gt;</code> tag that the user has just selected whenever they select one. In that case, you want to have something like:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function changeFunc() { var selectBox = document.getElementById("selectBox"); var selectedValue = selectBox.options[selectBox.selectedIndex].value; alert(selectedValue); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;select id="selectBox" onchange="changeFunc();"&gt; &lt;option value="1"&gt;Option #1&lt;/option&gt; &lt;option value="2"&gt;Option #2&lt;/option&gt; &lt;/select&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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