0

Below is my JSF

<h:selectOneMenu id="lstmonth"
required="true"
value="#{secdeal.month}">
<f:selectItem
    itemValue="JAN"
    itemLabel="01-January"/>
<f:selectItem
    itemValue="FEB"
    itemLabel="02-February"/>
<f:selectItem
    itemValue="MAR"
    itemLabel="03-March"/>

In javascript (In same file)

I want to read the selecteditem's itemLabel's text. (i.e: If I select 01-January, I want the same text into my var x)

x=getElementById('Form:lstmonth').itemLabel // not working x=getElementById('Form:lstmonth').innerText // not working -- returning all months

How to get the itemLabel text? please suggest

Actually I want x=01-January (selected item)

4

1 回答 1

0

干得好:

var ele = document.getElementById("Form:lstmonth");
var selectedIndex = ele.selectedIndex;
var x = ele.options[selectedIndex].text;
于 2017-03-16T12:26:10.650 回答