formscss-tablestrinidad

How to obtain number of selected rows in tr:table using Javascript?


Let's say I have the following table in my XHTML page:

<tr:table id="listRowsTable" var="bb"
    value="#{backingBean.results}"
    emptyText="Empty" width="100%"
    rowSelection="multiple"
    binding="#{backingBean.table}"
    rows="#{backingBean.numRows}"
    rowBandingInterval="1">

I'd like to implement a client-side check, such that when the user clicks on the submit button, if the number of rows selected exceeds a certain number then a prompt appears asking him/her to confirm his/her submission.

Can this be done using Javascript? If so, how should I proceed?


Solution

  • You could use jQuery to get the elements and then check if .length is what you expect but although i am not sure exactly how i would do something like this

    if($('tr:selected').length > SOMETHING){
        //do anything
    }