Jump to content

How to - Click to edit?


leon_nerd

Recommended Posts

Hi Guys,

 

I am currently working on a php based web application. I am kinda new to this. I want to implement something like "click to edit title" for picture in my website. This is one of those things where u can simply click the text and it becomes editable and as soon as the focus is taken off that block it is saved. Now the later part of saving on blur is clear to me. But the problem is how to achieve this "click to edit title" effect?

 

You can see such kind of effects on many web 2.0 websites. I tried googling but seems like I was not looking using the right terminology.

 

So any help in this regard will be highly appreciated.

 

Thanks.

Link to comment
Share on other sites

This is called AJAX (Asynchronus JAvascript and Xml). AJAX is always done with javascript, and usually combined with a server side language. And often, that server-side language returns XML.

In the situation of which you are speaking, you would make it so that javascript 'listens' for the edit link to be clicked. When it is clicked, it reads all the text to be edited, and removes the element (most likely a p tag) from the page, replacing it with an input of type text, and then inserts the text it read into this input. Next, when the user clicks finished or submit, javascript then reads in the new text, and passes that text to a script on the server in the background. The script on the server then inserts it into the database, and passes back something to tell the javascript whether it successfully entered the data into the database or not. If it was successfully entered, the text input is then changed back to a new element (again, most likely a p tag) and the text is inserted into it.

 

Thats the theory behind it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.