嗨,我正在使用 jquery。就像,
<script type="text/javascript">
$(function() {
$('#usertype').change(function() {
$.post("<%=request.getContextPath()%>/CommonServlet", {utype:$('#usertype').val(),funName:'getConfigMast'}, function(j){
$("input#it").html(j);alert(j);
});
});
});
</script>
在这个 j contians 中,我必须在同一个 jsp 页面中迭代他的对象,并且必须在 <table>
的文本字段中显示这些值。 。这里,当我从相同 <table>
的组合框中选择值时,将调用 jquery 函数。
和jsp表:
<table >
<tr>
<td><input name="filetype" type="text" class="formTxtBox_1" id="filetype"/></td>
</tr>
<tr>
<td>
<select name="usertype" id="usertype" >
<option >- Select Type of User -</option>
<option value="admin"> administrator </option>
<option selected="true" > normal</option>
<option> member</option>
</select> </td>
</tr>
<tr>
<td><input name="singlefile" type="text" id="singlefile"/></td>
</tr>
<tr>
<td><input name="totalfile" type="text" id="totalfile"/></td>
</tr>
<table>
最佳答案
需要使用 val()
设置输入字段的值函数,而不是 html()
。
$('#singlefile').val(value);
关于javascript - 如何在jsp中访问javascript值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4353577/