我有一个下拉菜单,但是当用户单击一个下拉菜单值时,它将显示json格式的结果,例如:[{"id":"11111","label":"PROGRAMMER","value":"1111"}
。而不是该json-我想显示我在jquery中下面的表。在这种情况下可以吗?我只想在用户选择下拉值时显示我的表格。谢谢你的帮助。
这是我的代码:
<table class="table">
<tbody>
<tr>
<th></th>
<c:forEach var="stepNumber" begin="1" end="#{testBean.jobEntity.stepSize}" varStatus="loop">
<c:if test="${loop.index lt 9}">
<th class="right-header">Step #{stepNumber}</th>
</c:if>
</c:forEach>
</tr>
<c:forEach items="#{testBean.jobEntity.jobRows}" var="jobRow">
<tr class="odd">
<td class="left-header">#{jobRow.rateType}</td>
<c:forEach items="#{jobRow.steps}" var="step" varStatus="loop">
<c:if test="${loop.index lt 8}">
<td class="left-header">#{step.amount}</td>
</c:if>
</c:forEach>
</tr>
</c:forEach>
</c:if>
</div>
</f:view>
<script type="text/javascript">
$( "#sJobClass" ).on("change", function() {
var jobClassCd = $(this).val();
if (jobClassCd !== 0) {
$.post('http://localhost:8080/myApp/JobSearchItem.xhtml',
function(data) {
$('#results').append(JSON.stringify(data) + '<br/><br/>');
});
}
});
</script>
带有jstl / jsf标签的html:
<select class="selectMenuSize" id="sJobClass" name="sJobClass">
<option value="">Choose</option>
<c:forEach items="#{myBean.jobSearchItems}" var="searchItem">
<option value="#{searchItem.getSearchValue()}" id="searchInputField"
name="searchInput">#{searchItem.toString()}</option>
</c:forEach>
</select>