简体   繁体   English

如何在jsp中访问javascript值?

[英]How to access javascript value in jsp?

Hi i am using jquery. 嗨,我正在使用jQuery。 like, 喜欢,

 <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>

in this j contians some model object i have to iterate his object in my same jsp page and those values i have to show in text fields in <table> . 在这个j contians中,一些模型对象必须在同一jsp页面中迭代他的对象,并且这些值必须在<table>文本字段中显示。 here the jquery function will called when i selected the the value from combobox of same <table> 在这里,当我从同一<table>组合框中选择值时,将调用jquery函数

and jsp table: 和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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM