Ajax instant edit
A small piece of javascript reads al SPAN tags, checks if it has class="editText" and a id=. If that is true, it adds a onclick function. That onclick function will create a textfield or input (depending on the size of the editable text). Someone has the ability to edit the field. When the text field is blurred, it will read the contents, and starts a XMLHttpRequest and 'sends' the content + fieldname + any set vars to an update file. That file will update your database, and reply with the newly set text and the textfield will dissapear again.
This is a very simple script which only works with span tags. Text from the span html tag is sent to update.php which process the request. Plain html is returned from the server and this result populates the span.
This example does not work unless you know how and what is in the update.php file Can you please post the update.php file that way it will make this example relevant. Or you can just email it to me at the above address. Thank you.
The update.php file receives its data via GET so you can simply check for the defined elements and do what ever you want to them via get.
The update.php file receives its data via GET so you can simply check for the defined elements and do what ever you want to them via get. email:3507072@gmail.com
When I implement this script it works fine the first time you click on a span to edit, but the second time you click that span it blanks out and doesn't preserve the original value at all. Any ideas why that would happen?
Cheers, at mine it works fine, but I could run the storage on txt-files. Please help!
How about permissions? Rights to edit the file?
it it's awsome!
Alt special characters not handled!!!!! Eg. º
a textarea ,a div ,can do it!
this is awesome. works great. I think that, if needed, people need to remember to but a final echo with the $content at the end of their update.php files. i had forgot it at first and then realized. everything else is simply get and manipulating the data strings.
You might want to secure this in some way, since it currently permits HTML and scripting to be edited into the field and executed within the SPAN.
Having some trouble with <p>, </p> why ?
Having some trouble with <p>, </p> why ? Sorry for the last message =)
Its real good
I like it but what common use can it have? This is just lame parlor tricks.
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
js error, if you delete all text in the field and save that....
Its Really nice to have such sites and regarding the codes-> it is Very nice and understandable.Thank You.
hello hello
buena pagina
This is very good example.
hi, Can forward the complete code for update.php for data base so that we can understand.
i also want save in data base of this value
can i get the code of this "comment on" form
this is awesome, but anyone have a coldfusion version? my php knowledge is very limited and dont need it for php.
a This is smaple comen
This is nice, and I got it working and all, but how can I get it to save permanently so when the page is refreshed the content is still there.
just a test comment
This is Perfect....
How would you modify this so that it actually saves the text as I type it? at the moment it ignores hard-returns so I couldn't type in a new-line or paragraph....
this is gr8 man
but can real time changes be seen elsewhere
I tried and love it. Thanks for that great sharing.
دردشة بوند
Muchas gracias por este aporte, es imprescindible!
Hi I try to run this script but it dosnt save the information, i can click and type but dont save the information that i type.
Hi I try to run this script but it dosnt save the information, i can click and type but dont save the information that i type.
I like this example.Thank you
it works ok; but if you want for example to write only numbers, how can you check this?
Great work, thanks a lot!
I would like to use this script but how can I update the new entered data into my database?
how do i apply validation to ensure that the edited content is also validated before it is saved. i want both client and php server side scripts.
pretty nice.
Thanks for wounder full site.
I get help and learn from this
Nice and easy, well done. Thanks
It just keeps returning "false" in the text field. the update.php is in the same folder. even tried the fix suggested by Sarfraz. Been trying for about an hour, no additional coding, just simply uploaded and test to no avail. atleast the edit box works, but the display of the update is a no go.
it's nice.. :)
Thx more sample content please.
Don't work if the user insert a long text with more than 2.800 characters!!!