Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将内联编辑的td值传递到数据库_Javascript_Jquery_Html_Ajax - Fatal编程技术网

Javascript 如何将内联编辑的td值传递到数据库

Javascript 如何将内联编辑的td值传递到数据库,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我正在使用javascript制作带有内联编辑的html表格,当表格td使用内联编辑进行编辑时,我想将编辑后的值保存在数据库中,我不知道如何将编辑后的值传递到数据库并保存,请任何人指导我如何做谢谢 我的java脚本 <script type='text/javascript'> window.onload=function(){ $("table td").click( function( e ){ if ( $(this).find('input').length ) {

我正在使用javascript制作带有内联编辑的html表格,当表格td使用内联编辑进行编辑时,我想将编辑后的值保存在数据库中,我不知道如何将编辑后的值传递到数据库并保存,请任何人指导我如何做谢谢

我的java脚本

<script type='text/javascript'>
window.onload=function(){
$("table td").click( function( e ){

    if ( $(this).find('input').length ) {
         return ;   
    }        
    var input = $("<input type='text' size='5' />")
                      .val( $(this).text() );

    $(this).empty().append( input );

    $(this).find('input')
           .focus()
           .blur( function( e ){
                  $(this).parent('td').text( 
                     $(this).val()
                  );
            });               

});  

</script>

window.onload=function(){
$(“表td”)。单击(函数(e){
if($(this).find('input').length){
返回;
}        
变量输入=$(“”)
.val($(this.text());
$(this).empty().append(输入);
$(this.find('input'))
.focus()
.blur(函数(e){
$(this.parent('td')。文本(
$(this.val()
);
});               
});  
Html


编辑

可以有多种方法来完成您的任务。我想说的是,在单击函数上使用ajax调用,并将该数据传递到一个新页面,该页面查询表中的更新数据

下面是有关使用ajax调用的详细信息


看看这个,不要重新发明轮子,但这里我使用的是javascriptjavascript或jquery,这是一件同样的事情,u jst需要进行ajax调用,将控件转移到编写了更新查询的页面,并将值与ajax调用一起传递。
 <html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> edit</title>
</head>
<body>
  <?php
$dbHost = 'localhost'; // usually localhost
$dbUsername = 'fms';
$dbPassword = 'xxxxx';
$dbDatabase = 'fms';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");     
$sql = mysql_query("SELECT * FROM supplierprice");       
echo "<table border='1'>
<tr>
<th>Region</th>
<th>Country</th>
<th>Network Name</th>
<th>Mcc</th>
<th>Mnc</th>
<th>Mnp</th>        
</tr>";    
while($row=mysql_fetch_array($sql))
{
echo "<tr>";
echo "<td>" . $row['region'] . "</td>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['networkname'] . "</td>";
echo "<td>" . $row['mcc'] . "</td>";
echo "<td>" . $row['mnc'] . "</td>";
echo "<td>" . $row['mnp'] . "</td>";
echo "</tr>";
}
echo "</table>";       
?>      
</body>
</html>