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