【发布时间】:2019-01-28 14:46:40
【问题描述】:
我的问题是:
我有一个 jsp、java 和 jquery 中的人员列表,我有 2 个输入姓名和年龄,我想用它们来过滤带有按键事件的列表。
Classes:
Person{
Id id;
string age;
string others;
getters and setters
}
Id{
string name;
string surname;
getters and setters
}
我想从 id 中获取 jquery 值:
JAVA:
List<Person> list_of_persons; //It has some persons in it
map.put("list", list_of_persons);
HTML:
<% int i = 0; %>
<input type="text" id="filter_name"/>
<input type="text" id="filter_age"/>
<c:forEach items="${map.list}" var="listPerson" id="list_of_persons">
<% i++; %>
<div class="row reg_<%=i%>">
<div class = "col-md-2">
<input type="text" class="form-control" id="person_name_<%=i%>"
value="<c:out value="${listPerson.getId().getName()}"/>"/>
</div>
<div class = "col-md-2">
<input type="text" class="form-control" id="person_age_<%=i%>"
value="<c:out value="${listPerson.getAge()}"/>"/>
</div>
<div class = "col-md-2"><input type="text" class="form-control"
id="person_others_<%=i%>"
value="<c:out value="${listPerson.getOthers()}"/>"/>
</div>
</foreach>
</div>
jquery:
namekeyupevent(){
//want to filter the list with the name on keyup
//Should i compare input name with each object of the list?
// if so how can i get the name from the list?
// Something like this would be ok?
$('.list_of_persons).each(function(){
var text = $(this).id.name;
}
agekeyupevent(){
//want to filter the list with the age on keyup
}
感谢您的帮助。
您好。
【问题讨论】:
标签: javascript jquery ajax jsp filtering