duanke3985 2016-06-27 12:09
浏览 163
已采纳

实时更新php变量并同时显示文本框中的值

This is my table row click function in the file, 'BAConsult.php'. On click, showconsultationdata function will run.

$(document).ready(function(){ //table row click
  }).on('click','.consultclick tr',function(e){   
      if(e.target.tagName === "TD"){
          $(".consultclick tr").removeClass("highlight");
    $(e.target).parent().addClass("highlight");    
      }      
    var dateconsulted = $(this).attr('value'); 
    alert(dateconsulted);
    showconsultationdata(dateconsulted);
});

This is my ajax script

function showconsultationdata(str) { 
if (str == "") {
    document.getElementById("txtHint2").innerHTML = "";
    return;
} else { 
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else {
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("txtHint2").innerHTML = xmlhttp.responseText; 

        }
    };
    xmlhttp.open("GET","BAConsultRecordsAJAX.php?q="+str,true);
    xmlhttp.send();
}
}

Here is another php file called 'BAConsultRecordsAJAX.php' where i placed the ajax of the showconsultationdata.

session_start();
require('Config/Setup.php');
$q = $_GET['q']; 
$consult="SELECT * FROM Counsel where nric='$_SESSION[nric]' and dateconsulted='$q'";

$consultresult = mysqli_query($dbconn,$consult);

while($row = mysqli_fetch_array($consultresult)) {
$skincareremarks=$row['skincareremarks'];
$skinconditionremarks=$row['skinconditionremarks'];
}

On table row click, $skincareremarks and $skinconditionremarks should be updated. And these values will show up in the textboxes in the 'BAConsult.php' page. How can i do this?

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥50 有没有大佬看一下关于思科的这道题怎么做
      • ¥30 求十字路口交通灯S7-200plc,今天早上八点前。
      • ¥20 如何用智能手表oppowatch3实现个人热点功能
      • ¥15 运营商打开wanpush会有怎么样的危害
      • ¥15 Java编程题,定义一个时钟
      • ¥15 Python面向对象编程——生成多项式的一阶导数
      • ¥15 在编写C++程序遇到了问题
      • ¥15 java程序查找字符串中所有的回文并输出
      • ¥15 怎么让只支持对.exe 和.dll文件进行加壳的加壳器,同时让它也支持php文件加壳呢
      • ¥15 这两个数学公式什么意思?