[英]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");
});
jQuery有一个.val()函数,可以执行您想要的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.