2014-10-08 82 views
0

一个textarea我在其中的内容将与每次复选框显示在排序列表一个div。这些通过从数据库中提取来显示。现在我需要显示选定复选框附近的内容。我做了什么至今编辑jquery的弹出框

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

到目前为止,这是可以正常使用。但现在我需要在弹出窗口中的文本区域中显示<p>标签的内容,其ID为p_id。然后编辑文本,并通过单击弹出框的更新按钮,必须在db中更新内容。

谁能帮我找到了一个解决方案。

+0

js请稍候。 – 2014-10-08 13:01:38

回答

0

你需要创建一个PHP文件,将从数据库接收行ID,并将其打印到textarea的一种形式。当用户点击提交时,表单动作会更新数据库。下面是你需要做什么,一步一步的指导:?

  1. 添加一个“A”标签,它会打开popup.php ID = 1(其中1是行的id)
  2. 创建弹出PHP文件,从数据库
  3. 取记录添加一个表单元素与文本区域和popup.php提交按钮和填充您的textarea在步骤2
  4. 要么获取的值创建一个名为新文件update.php或检查如果页面在弹出式php中有post请求,并使用给定的id和textarea值更新db中的值。

希望这会帮助你完成。

+0

但我怎样才能显示他们作为一个jQuery的弹出框? – Zammuuz 2014-10-09 03:48:09

+0

如果你想要一个“模式”框,我建议你使用fancybox(http://fancyapps.com/fancybox/)或colorbox会做的伎俩(http://www.jacklmoore.com/colorbox/)。当你说弹出窗口时,我以为你会用window.open函数打开一个实际的弹出窗口。但模态框也会这样做。 – artuc 2014-10-09 12:55:55