Reputation: 137
I am trying to pass a value after the onchanged event of the userList
<select id="userList">
<c:forEach var="staff" items="#{systemUtil.allStaff}" >
<option value="${staff.id}">${staff.username>
<c:if test="${param.selectValue == staff.id})"> selected </c:if>
</option>
</c:forEach>
</select>
The on change will call this function. I was able to get the correct selected value but i couldn't seem to pass the value into systemUtil.someString(selectedValue), which is my managed bean. When i try to print out the value within the someString method, all i got was null.
After tracing through the code, it seems like this assignment is done even before the onchanged event.
What am i doing wrong?
$(document).ready(function(){
$("#userList").change(function(){
// alert($(this).find("option:selected").text()+ "1");
// alert( $("#userList").val()+"test");
var selectedValue = $("#userList").val();
alert(selectedValue + "teee");
var test = ${systemUtil.someString(selectedValue)};
alert(test + "teee2");
Upvotes: 0
Views: 151
Reputation: 31
if u writer anything inside ready function obviously it will assign when the jsp loads, not when onchange, so don't call this function in side ready. because of this you are getting the null values.
Upvotes: 0