0

Is there a way to access to an id of selectItem JSF from JavaScript or jQuery?

<a:commandButton id="ajaxButton" value="change" onclick="selectCheck()">
</a:commandButton>

<h:selectManyCheckbox id="check" >
    <f:selectItem id="myCheckbox" itemLabel="India" itemValue="India"  />
    <f:selectItem itemLabel="China" itemValue="China" />
    <f:selectItem itemLabel="Germany" itemValue="Germany" />
    <f:selectItem itemLabel="USA" itemValue="USA" />
</h:selectManyCheckbox>

I try to access the id of the component but it returns null:

function selectCheck() {
    var obj = document.getElementById("myCheckbox");
    alert(obj);
    obj.checked=true;
}

I want to check any of theses checkboxes dynamically by JavaScript or jQuery.

1

1 Answer 1

1

Have you looked at the generated html to see if thats really the id of the element? JSF usually prepends the id of the form and some other container elements. The real id might be something like myForm:myCheckbox.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks; the html generate other id for my component.it's solved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.