-1

I have a selectOneRadio component containing some selectItem elements:

<h:selectOneRadio id="attribute_type" layout="pageDirection" styleClass="required radioBtn"
                  value="#{bean.someField}"
                  onclick="this.form.submit()"
                  valueChangeListener="#{bean.someMethod}">
    <f:selectItem styleClass="radiob" itemLabel="something1" itemValue="0" />
    ...
    <f:selectItem class="rad"  itemLabel="somethingN" itemValue="3" />                     
</h:selectOneRadio>

I want to get the value of the selected button, but as you can see, the ids starts with "form:attribute_type:" They are like: form:attribute_type1, form:attribute_type2...

enter image description here

Using this example doesn't work.

var radioButtonValue = $('[id^=form:attribute_type]').value

enter image description here

or var radioButtonValue = $('[id^=form:attribute_type]').value enter image description here

Could you tell a sintax to select by id starting with some pattern?

Community
  • 1
  • 1
Nelly Junior
  • 556
  • 2
  • 10
  • 30
  • BalusC, the answer you provided in the question that you marked as duplicate doesn't help me at all. You specified there that for the id="foo:bar" should be used var $element1 = $("#foo\\:bar"); or var $element2 = $("[id='foo:bar']"); or var $element3 = $(document.getElementById("foo:bar"));. So, in my case I see you would apply the sintax specified for $element2. – Nelly Junior Sep 20 '16 at 08:11
  • @BalusC: First, the question is not duplicate to the one you marked because I am looking for a id starting with. But if I would combine the syntax you provided for $element2 and the answer marked as correct in the page mentioned to my post would be: $("[id^='form:attribute_type:']"); and it doesn't work. – Nelly Junior Sep 20 '16 at 08:11
  • Well, how could I do to make it work? If there is an answer, please give me the exampla that work in my case. – Nelly Junior Sep 20 '16 at 12:44

1 Answers1

0

You store the selected value in "#{bean.someField}". Why don't you get it from there?