简体   繁体   English

当我单击编辑图像时,我希望我的编辑功能能够正常工作

[英]I would like to have my edit function to work when i click on the edit image

I would like to have my edit function to work when i click on the edit image. 当我单击编辑图像时,我希望我的编辑功能能够正常工作。 I have a function to edit an event but it wont work when i click on the image. 我具有编辑事件的功能,但是单击图像后它将无法正常工作。 The delete code works when i click on the event: delete function/edit function: 当我单击以下事件时,删除代码有效:删除功能/编辑功能:

  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><a><img src="../../images/delete.png" title="delete" width="14" id="delbut'+event.id+'" border="0" style="padding-right:5px; padding-top:2px;" /></a></div>';
                $(this).append(layer);
                $("#delbut"+event.id).hide();
                $("#delbut"+event.id).fadeIn(300);
                $("#delbut"+event.id).click(function() {
                $.ajax({
                url: '<?=base_url();?>testcalendar/fullcalendar/delete_events.php',
                data: 'id=' + event.id ,
                type: "POST",
                });
                var nTime = 1 * 50;
                window.setTimeout("location.reload()", nTime);
                });
                $("#edbut"+event.id).hide();
                $("#edbut"+event.id).fadeIn(300);
                $("#edbut"+event.id).click(function() {
                    var title = prompt('Current Event Title: ' + event.title + '\n\nNew Event Title: ');

                    if(title){
                $.ajax({
                url: '<?=base_url();?>testcalendar/fullcalendar/update_title.php',
                data: 'title='+ event.title+'&id='+ event.id ,
                type: "POST",
                });
                    }
                });
            },

delete_events.php: delete_events.php:

<?php
$id = $_POST['id'];
 try {
 $bdd = new PDO('mysql:host=localhost;dbname=develop-calendar', 'root', 'root');
 } catch(Exception $e) {
  exit('Unable to connect to database.');
 }
$sql = "DELETE from evenement WHERE id=".$id;
$q = $bdd->prepare($sql);
$q->execute(array($id));
?>

update_title.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', 'calendar-boks', '19xantia');
 } 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();
?>

When i click on the edit icon there is an prompt to edit the title but when i type in a new title and click on ok it wont update. 当我单击编辑图标时,会提示您编辑标题,但是当我键入新标题并单击确定时,它将不会更新。 i think that there is something wrong with my update_title.php file but i dont know for sure. 我认为我的update_title.php文件出了点​​问题,但我不确定。

There is a problem here 这里有问题

 $sql = "UPDATE evenement SET title=".$title "WHERE id=".$id;

Needs to be 需要是

 $sql = "UPDATE evenement SET title=" . mysql_real_escape_string($title) . " WHERE id=" . mysql_real_escape_string($id);

Indeed, the space before WHERE I edited already on previous answer. 确实,在我之前编辑的WHERE之前的空格中。

You can also always try to debug what is returning by the script if you look into the Network tab inside Developer Console (F12 in most browsers). 如果您查看开发者控制台(在大多数浏览器中为F12)内的“网络”标签,也可以始终尝试调试脚本返回的内容。

Or check the results of the ajax call. 或者检查ajax调用的结果。

$.ajax({
  url: '<?=base_url();?>testcalendar/fullcalendar/delete_events.php',
  data: 'id=' + event.id ,
  type: "POST",
}).done(function(data) {
  alert(data); // Only for testing
});

暂无
暂无

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

相关问题 我想让我的图片弹出时变大 - I would like to make my image pop out larger when I click on it 在我的布局中,当我单击编辑文本时,在编辑文本下方有一个编辑文本和一个按钮,然后在软输入上方显示布局 - In my layout one edit text and one button below edit text when i click on edit text then layout show above the soft input 我有一个文本框,我希望用户单击按钮时可以切换到网格。 在asp.net中可以吗? - I have a textbox which I would like to allow my users to switch to a grid when they click a button. Is this possible in asp.net? 我对编辑功能有一个特别的想法 - I have a Special Idea about an Edit function 我应该如何编辑我的JavaScript,以便能够单击html列表? - How should I edit my javascript so that I have the ability to click through a html list? 一切正常,但当我点击编辑按钮时,每次都会添加一个逗号(,)。 我不会发现出了什么问题? - Everything works fine but when I click edit button, a comma (,) is add every time. I would not find what going wrong? 如何在浏览器中编辑 javascript,就像我可以使用 Firebug 编辑 CSS/HTML 一样? - How can I edit javascript in my browser like I can use Firebug to edit CSS/HTML? 双击某列时如何编辑它? - How can I edit a column when I double click on it? 为什么当我单击“喜欢”图像时,ajax函数无法执行? - Why is the ajax function not executing when I click on the 'like' image? 当我点击按钮编辑我的值时,状态不会更新输入值 - When I click on button to edit my value, the state don't update the input value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM