【问题标题】:How to access javascript value in jsp?如何在jsp中访问javascript值?
【发布时间】:2010-12-04 12:56:21
【问题描述】:

您好,我正在使用 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 中包含一些模型对象,我必须在我的同一个 jsp 页面中迭代他的对象,并且我必须在 &lt;table&gt; 的文本字段中显示这些值。当我从相同&lt;table&gt;的组合框中选择值时,将调用 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>

【问题讨论】:

    标签: javascript jquery ajax jsp


    【解决方案1】:

    输入字段的值需要使用val()函数设置,而不是html()

    $('#singlefile').val(value);
    

    【讨论】:

      猜你喜欢
      • 2014-01-11
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      • 2020-11-23
      • 2014-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多