繁体   English   中英

Javascript:如何使用填充了参数的字段打开表单?

[英]Javascript: How to open a form with fields filled with parameters?

我想打开一个表单,其字段填充有与某个记录对应的数据。

例:

  • 假设某种形式:

    小狗

      <table id="tabledogs" class="ui-widget ui-widget-content"> <thead> <tr class="ui-widget-header "> <th>ID</th> <th>Name</th> <th>Action</th> </tr> </thead> <tbody> <c:forEach var="dog" items="${sessionScope.dogs}"> <tr> <td width="50%" align="left">${dog.id}</td> <td width="50%" align="left">${dog.name </td> <td><button id="update">Update</button> </td> </tr> </c:forEach> </tbody> </table> </div> 
  • 我想打开下面的表单,其中包含相应的狗数据(这里没有显示其他表单配置以节省空间):

      <form> <fieldset> <label for="id">ID</label> <input type="text" name="id" id="id" class="text ui-widget-content ui-corner-all" /> <label for="name">Name</label> <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" /> </fieldset> </form> </div> 

对于虽然我拥有以下JavaScript,但将打开表单但不包含数据:

$("#update").button().click(function() {
    $("#dialog-form").dialog("open");
});
  • 所有这些东西都正常工作。 如何将狗的数据传递到要显示的表单? 如您所见,我在SessionScope中有一组“狗”对象。 感谢您的帮助!

jQuery有一个.val()函数,可以执行您想要的操作。

暂无
暂无

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

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