【发布时间】:2014-02-26 13:18:53
【问题描述】:
所选事件的标题需要更改为提示输入的任何内容。
但它没有按预期工作。请建议/建议
JavaScript 函数:
eventMouseover: function(event, domEvent) {
var layer = '<div id="events-layer" class="fc-transparent" style="position:absolute; width:100%; height:100%; top:-1px; text-align:right; z-index:100"><a><img src="../../images/editbt.png" title="edit" width="14" id="edbut'+event.id+'" border="0" style="padding-right:3px; padding-top:2px;" /></a></div>';
$("#edbut"+event.id).hide();
$("#edbut"+event.id).fadeIn(300);
$("#edbut"+event.id).click(function() {
var title = prompt( '\n\nNew Event Title: ');
if(title){
$.ajax({
url: '<?=base_url();?>testcalendar/fullcalendar/update_title.php',
data: 'title='+ event.title+'&id='+ event.id ,
type: "POST",
});
}
});
},
PHP 表单(update_title.php):
<?php
$id = $_POST['id'];
$title = $_POST['title'];
// connection to the database
try {
$bdd = new PDO('mysql:host=localhost;dbname=blackboks-calendar', 'root', 'root');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
// update the records
$sql = "UPDATE evenement SET title=". $title ."WHERE id=".$id;
$q = $bdd->prepare($sql);
$q->execute();
?>
【问题讨论】:
-
你在哪里发送ID? - 目前您只有标题,所以您的
WHERE语句将为 null / nothing -
你的 JS 函数在 PHP 文件中吗?并尝试
"UPDATE evenement SET title='". $title ."' WHERE id=".$id; -
在 标签之间是的
-
试试你的 SQL 查询?我想你可能在那里。
标签: javascript php post fullcalendar prompt