javascript - 如何在jsp中访问javascript值?

标签 javascript jquery ajax jsp

嗨,我正在使用 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/

相关文章:

javascript - 将 UTC 日期转换为日期时间字符串 Javascript

javascript - fullPage.js 没有缓动

javascript - 使菜单打开时标题内容消失

javascript - 在选择框的特定位置设置滚动条

php - 需要 $.ajax 函数的帮助 - 如何发送关联数组?

javascript - 前一个完成时的多个 ajax 调用

javascript - javascript中如何获取所有的li?

javascript - 清除启动动画 javascript 返回未定义

jQuery 添加类在单击另一个类时删除

javascript - 在 Express 服务器上获取从 AJAX 发送的数据