在jquery弹出框中编辑文本区域

edit a textarea in jquery popup box

本文关键字:编辑 文本 区域 jquery      更新时间:2023-09-26

我有一个div,其中的内容显示在有序列表中,每个列表都有一个复选框。这些是通过从数据库中获取来显示的。现在我需要在选中的复选框附近显示内容。到目前为止我做的是

1) only one check box can be selected at a time
2) get the id of the check box which is selected stored to variable ids
3) then paragraph content id = "p"+checkbox id

代码为:

$(document).ready(function(){
    $(':checkbox').bind('change', function() {
        var thisClass = $(this).attr('class');
        if ($(this).attr('checked')) {
            $(':checkbox.' + thisClass + ":not(#" + this.id + ")").removeAttr('checked');
        }
    });
});
function edit_temp(prt){
        var checkedAtLeastOne = false;
            $('input[name="check_clinic"]').each(function() {
                    if ($(this).is(":checked")) {
                       checkedAtLeastOne = true;
                       ids = $(this).attr('id');
                        }
                    });
                    if(checkedAtLeastOne){
                         p_id ="p"+ids;
                      alert(p_id);
                       }
                    else{
                          alert('Please select any clinical Interpretation');
                    }
        }

到目前为止,这是完美的工作。但现在我需要在弹出窗口内的文本区域中显示id为CCD_ 2的CCD_。然后编辑文本,点击弹出框的更新按钮,内容必须在数据库中更新。

有人能帮我找到解决办法吗。

您需要创建一个php文件,该文件将从数据库接收行id,并将其打印到表单中的文本区域。当用户单击提交时,表单操作将更新数据库。以下是您需要做的分步指南:

  1. 添加一个打开popup.php的"a"标记?id=1(其中1是行的id)
  2. 创建popup.php文件,从数据库中获取记录
  3. 在popup.php中添加一个带有textarea和submit按钮的表单元素,并用步骤2中获取的值填充您的textarea
  4. 创建一个名为update.php的新文件,或者检查页面是否在popup php中有post请求,并使用给定的id和textarea值更新db中的值

希望这能帮助你完成。