Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

391
Views
How can I get value of checked JSF radiobutton using JS?

I have JSF facelet like this:

<h:form id="input-f">
    <div>
        <h:outputLabel for="coord-x" value="Choose X:"/>
        <p:panelGrid columns="2">
            <h:selectOneRadio id="coord-x" required="true" value="#{resultBean.newResult.r}">
                <f:selectItem class="xGroup" itemValue="-2" itemLabel="-2"/>
                <f:selectItem class="xGroup" itemValue="-1.5" itemLabel="-1.5"/>
                <f:selectItem class="xGroup" itemValue="-1" itemLabel="-1"/>
                <f:selectItem class="xGroup" itemValue="-0.5" itemLabel="-0.5"/>
                <f:selectItem class="xGroup" itemValue="0" itemLabel="0"/>
                <f:selectItem class="xGroup" itemValue="0.5" itemLabel="0.5"/>
                <f:selectItem class="xGroup" itemValue="1" itemLabel="1"/>
                <f:selectItem class="xGroup" itemValue="1.5" itemLabel="1.5"/>
                <f:validateRequired/>
            </h:selectOneRadio >
        </p:panelGrid>
    </div>
    <div>
        <h:outputLabel>Available Y values: (-5 ... 5)</h:outputLabel>
        <p:panelGrid columns="2">
            <p:inputText maxlength="17" name="y" id="coord-y"
                                         placeholder="(-5..5)" value="#{resultBean.newResult.y}">
            </p:inputText>
        </p:panelGrid>
    </div>
</h:form>

And I try use JS script for getting values of this form after form submitting:

x = $("#input-f\\:coord-x input[type='selectOneRadio']:checked").val();
y = document.getElementById("input-f:coord-y").value;

I can correctly get "y" value, but can't get "x" value. Logging says, that "x" is undefined. I tried use .getElementById() method, but it hasn't be successfull too. How can I use JS for getting checked "x" value?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!