Kay1021 Posted May 30, 2009 Share Posted May 30, 2009 Not sure if this belongs here.... i'm trying implement an inline edit feature into my website and it has to use Mootools. I found this one http://davidwalsh.name/editable-content-mootools-php-mysql Below are the different parts from my code. It almost seems like it works but then it's not updating the content in the database. So when i refresh the page the content reverts to what it was before. HTML: <p class="editable textarea" title="Content Paragraph" rel="'.$cat_id.'" color="black">'.$comment.'</p> JS: //once the dom is ready window.addEvent('domready', function() { //find the editable areas $$('.editable').each(function(el) { //add double-click and blur events el.addEvent('dblclick',function() { //store "before" message var before = el.get('html').trim(); //erase current el.set('html',''); //replace current text/content with input or textarea element if(el.hasClass('textarea')) { var input = new Element('textarea', { 'class':'box', 'text':before }); } else { var input = new Element('input', { 'class':'box', 'value':before }); //blur input when they press "Enter" input.addEvent('keydown', function(e) { if(e.key == 'enter') { this.fireEvent('blur'); } }); } input.inject(el).select(); //add blur event to input input.addEvent('blur', function() { //get value, place it in original element val = input.get('value').trim(); el.set('text',val).addClass(val != '' ? '' : 'editable-empty'); //save respective record var url = 'table.php?id=' + el.get('rel') + '&comment=' + el.get('text'); var request = new Request({ url:url, method:'POST', onRequest: function() { alert('making ajax call :: ' + url); } }).send(); }); }); }); }); PHP & MySQL if(is_numeric($_POST['id']) && isset($_POST['comment'])) { $query = "UPDATE school1 SET comment = '".$_POST['comment']."' WHERE cat_id = ".$_POST['id']; $result = mysql_query($query,$db_link); } In the javascript it gives a little pop up that tells you what the url will be with the variables will equal....and everything seems good...but for some reason it's not updating to the database. If anyone can see something i'm doing wrong...or another mootools inline edit i could use. please let me know Thanks Link to comment https://forums.phpfreaks.com/topic/160281-solved-mootools-inline-edit-php/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.