richarro1234 Posted February 19, 2009 Share Posted February 19, 2009 Hello, i would like to know if its possible to have a form that will allow someone to update a text field with an onlcik (of offclick) so for instance, if i was to update my mood, it would show my current mood (which is set in the database) then, when i click on it, it will change to a text field so i can type my new mood in there, then when i click outside the box, it will save my mood as what i just typed. or maybe just have a "post" button next to the text, but it doesnt load a new page so it just updates the database without the page bein reloaded. Thanks Rich Link to comment https://forums.phpfreaks.com/topic/145858-question-about-onclick/ Share on other sites More sharing options...
niranjnn01 Posted February 19, 2009 Share Posted February 19, 2009 Hello.. This can be done with ajax.. and javascript.. and php use javascript to display the text box on the "OnClick" event, and then enter the data. ajax can be used to send this new data to ur database for updation. [u will need a php file to handle the data from ajax and update table at the other end]. now u can use javascript to specify, if the form [ie the text field, ]needs to be submitted when u click outside the text box, or with an update button. Learn more abt ajax, and javascript . u will get more ideas then Rakesh Link to comment https://forums.phpfreaks.com/topic/145858-question-about-onclick/#findComment-765795 Share on other sites More sharing options...
angelcool Posted February 19, 2009 Share Posted February 19, 2009 You can use a lot of techniques for this; Javascript,an HTML Form pointing to a PHP script, and AJAX. For the characteristics you mentioned(having your mood in a database) Javascript is discarded(only client side programming), then you have two options left: HTML form or AJAX. My opinion will be to use AJAX, because this prevents having to refresh your browser, on the other hand it is more complex to set. You can try HTML first and then move on. Angel Link to comment https://forums.phpfreaks.com/topic/145858-question-about-onclick/#findComment-765796 Share on other sites More sharing options...
richarro1234 Posted February 19, 2009 Author Share Posted February 19, 2009 i think ajax would be the way forwards for this. i just done a quick search on google about updating the DB and found a few script examples i might have a look at and see if i can find some usefull tutorials to help me on the way. Thanks for the help guys Rich Link to comment https://forums.phpfreaks.com/topic/145858-question-about-onclick/#findComment-765799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.