0

特定のレコードに対応するデータがフィールドに入力されたフォームを開きたいのですが。

例:

  • 特定の形式を想定します。

            <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には一連の「犬」オブジェクトがあります。助けてくれてありがとう!
4

1 に答える 1

0

Jqueryには.val()関数があり、必要な処理を実行できます。

于 2013-03-11T20:27:03.553 に答える