Javascript:如何打开一个字段填充参数的表单

Javascript: How to open a form with fields filled with parameters?

本文关键字:字段 一个 填充 参数 表单 何打开 Javascript      更新时间:2023-09-26

我想打开一个表单,它的字段中填充了与某个记录相对应的数据。

的例子:

  • 假设某种形式:

    <标题>狗

            <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()函数,它应该做你想做的。

相关文章: