如何检索表行到对话框和编辑 [英] how to retrieve table rows into dialog box and edit

查看:138
本文介绍了如何检索表行到对话框和编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的jQuery像这样

I have jquery like this

<script type="text/javascript">
$(document).ready(function () {
function fnOpenNormalDialog() {
            $("#dialog-editTweet").html("Tweet Edit Box");

            // Define the Dialog and its properties.
            $("#dialog-editTweet").dialog({
                resizable: false,
                modal: true,
                title: "Modal",
                height: 250,
                width: 400,
                buttons: {
                    "Yes": function () {
                        $(this).dialog('close');
                        callback(true);
                    },
                        "No": function () {
                        $(this).dialog('close');
                        callback(false);
                    }
                }
            });
        }

        $('.btnOpenDialog').click(fnOpenNormalDialog);

        function callback(value) {
            if (value) {
                alert("Tweet Edited");
            } else {
                alert("Rejected");
            }
        }


    });

我的表像这样

I have table like this

<fieldset id ="allTweets">

            <table cellspacing="20" class ="tweetTable"  >
            <caption>Tweets</caption>
    <%


        while(rs.next()){
    %>
            <tr id="ForChangingTweet">
                <td><%=rs.getString(1)%></td>
                <td><%=rs.getString(2)%></td>               
                <td><%=rs.getString(3)%></td>
                <td><input type="button" class="btnOpenDialog" value="Edit Tweet" /></td>
                <div id="dialog-editTweet"></div>

            </tr>

    <%
        }
    %>
        </table>
        </fieldset>
    <%

现在我想编辑对话框的形式,这样,当我将点击修改鸣叫按钮,就应立即检索最后两个,我会编辑的中间,在对话框box.I想用AJAX在我的jQuery将发送过去和编辑中间servlet和基于上次,我将修改数据库的价值。我不能改变过去,因为它是时间戳值。请告诉还如何使用Ajax,这将调用servlet来改变进数据库。我很新的jQuery的。

Now i want to edit the dialog box as form so that when i will click 'edit tweet' button it should immediately retrieve the last two and i will edit the middle in the dialog box.I want to use ajax in my jquery which will send last and edited middle to servlet and based on the value of last i will modify the database. I cannot change the last because it is timestamp value. please tell also how to use ajax which will call servlet to change into database. I am very new in jquery.

推荐答案

您都提出这个问题的多次。不要做这样的。增值你的问题尽量的简洁的文字和清晰后你都尝试过的和你在哪里卡住了?当然的提供,如果你有足够的赏金的得到解决这个快。

You were raising this question multiple times. Don't do like that. To add value to your question try to concise the text and clearly post what you were tried and where you are stuck? And of course provide if you have enough bounty to get solve this fast.

顺便说一句我张贴的一半的溶液为您服务。直到上编辑表值单击按钮。请找到$ C $下的模态获取表值。在脚本,

By the way i am posting half of the solution for you. Till editing the table values on click the button. Please find the code for getting table values in modal. In scripting,

 $("#firstTextBox").val($(this).parent().parent().find('td:eq(1)').text());
 $("#secondTextBox").val($(this).parent().parent().find('td:eq(2)').text());
 $("#thirdTextBox").val($(this).parent().parent().find('td:eq(3)').text());

在你的HTML稍微修改,

Slight modification in your HTML,

<div id="dialog-editTweet" style="display:none;">
    Name:  <input type="text" id="firstTextBox" name="firstTextBox" /><br>
    Age: <input type="text" id="secondTextBox" name="secondTextBox" /><br>
    Subject: <input type="text" id="thirdTextBox" name="thirdTextBox" /><br>
</div>

从这里就需要发送一个Ajax请求更新编辑的值到数据库。

From this you need to send an ajax request to update the edited values into DB.

下面是工作的 演示

PS:使用隐藏标识以更新的行。希望这会给起点。干杯。

PS: Use the hidden Id to update the rows. Hope this will give starting point. Cheers..

这篇关于如何检索表行到对话框和编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆