2013-03-11 24 views
0

我想打開一個表單,其中的字段中填有相應於某個記錄的數據。Javascript:如何打開填充參數的字段的表單?

實施例:

  • Supose一定的形式:

     <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中有一組「狗」對象。感謝您的幫助!

回答

相關問題