简体   繁体   English

在jquery弹出框中编辑textarea

[英]edit a textarea in jquery popup box

I have a div in which contents are displayed in ordered list with a checkbox for each. 我有一个div,其中内容显示在有序列表中,每个都有一个复选框。 these are displayed by fetching from the database. 这些是通过从数据库中获取来显示的。 now i need to display the content near to the selected check box. 现在,我需要在所选复选框附近显示内容。 what i did so far is 我到目前为止所做的是

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

The code is: 代码是:

$(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');
                    }
        }

So far this is working perfectly. 到目前为止,它运行良好。 but now i need to display the content of the <p> tag with id p_id in a text area inside a popup window. 但是现在我需要在弹出窗口内的文本区域中显示ID为p_id<p>标记的内容。 and then edit the text and by clicking the update button of popup box that content must be updated in db. 然后编辑文本,然后单击弹出框的“更新”按钮,必须在db中更新内容。

can anyone help me to find a solution for this. 谁能帮助我找到解决方案。

You need to create a php file that will receive the row id from database and prints it to textarea in a form. 您需要创建一个php文件,该文件将从数据库接收行ID,并将其以表格形式打印到textarea。 and when user clicks submit the form action will update the db. 当用户单击“提交”时,表单操作将更新数据库。 Here are the step by step guide what you need to do: 以下是逐步指南,您需要做什么:

  1. Add an "a" tag which opens popup.php?id=1 (where 1 is the id of the row) 添加一个“ a”标签以打开popup.php?id = 1(其中1是该行的ID)
  2. Create the popup.php file, which fetch record from database 创建popup.php文件,该文件从数据库中获取记录
  3. Add a form element with textarea and submit button in popup.php and populate your textarea with the value fetched in step 2 在popup.php中添加一个带有textarea的表单元素并提交按钮,并使用在步骤2中获取的值填充您的textarea
  4. Either create a new file called update.php or check if the page has post request in popup php and update the value in db with the given id and textarea value. 创建一个名为update.php的新文件,或者检查页面是否在php弹出窗口中具有发布请求,并使用给定的id和textarea值更新db中的值。

Hope this will help you to finish. 希望这会帮助您完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM