Q:

getting the dynamic ID value from variable

I have created dynamic id for a <slect> . Here is the code - 
    <% int i = 0; %>

    <c:forEach var="pro" items="${proofingListsWithRoles.allList}" varStatus="status">
        <tr>
            <td id="jobId">${pro.jobId}</td>
            <td>                            
                <select id="selectRole<%=i %>" onchange="javascript:selectRole('selectRole<%=i %>')">
                    <c:forEach items="${pro.roles}" var="rol" varStatus="status">
                        <option value="${rol.id}"> <c:out value="${rol.name}"/></option>
                    </c:forEach>                
                </select>
            </td>
        </tr>
        <% i++; %>
    </c:forEach>

Now my target is to find out which id of the selected role from dropdown.The followingalert()print selectRoel0, selectRole1, selectRole2,... . Notice selectRole0, selectRole1 etc are id of <select>. Since <slect> is in a forEach loop there are multiple <select>. Here inside the function(selectId){} seelctId is used get the value of selectRole0,selectRole1 .... and so on.So using the id of <select> inside function selectRole(selectId){} how can get which role is selected from the dropdown.
function selectRole(selectId){
    alert(selectId);
}

A:

Use the following inside the function. 
$('#' + selectId).val();

