[英]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.