Results 1 to 8 of 8

Thread: click, edit and save text script without refreshing page?

  1. #1
    Join Date
    Jul 2006
    Posts
    64
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Default click, edit and save text script without refreshing page?

    i'm looking for a script that will allow the users to click and edit text then save without reloading the page.

    example:

    Sample user text. (when user click on the text it turns into an editable field that they can change, then maybe a save button appears too or something to save changes to the database)

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    There's an easy way to do this without even needing Ajax (a style of coding which would allow javascript to transmit data to the server).

    Use an onChange event on the textbox, or onChange with onKeydown on a certain interval (after about 5 seconds of no change would be good), and then save that data to the server by submitting through an image.
    Change the src for the image to ...img.php?val=[the text will go here], using Javascript. Have that PHP script output an image (this isn't too hard) which will say "updated" (and could even give the current time), or could be small/invisible, if you want.

    When the page loads, just get the text from the file and load it into the textbox, with PHP. Easy.
    <?php echo file_get_contents('my.txt'); ?>

    The PHP image script will display the image in the end, but also save the data from the $_GET['val'] variable.
    $f = fopen('text.txt','w+');
    fwrite($f,$_GET['val']);
    fclose($f);

    tech_support (another user here) and I had a working example of this a while ago on his server. I think he probably still has a copy. I'll ask him to post that.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I know this is an old threadw...
    Do you still have this?

    I'm looking for something like this.

  4. #4
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    Sorry for feeding an old thread.

    I have attached a script that might work for you.

  5. #5
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks
    I'll look at it when I get home after working in the morning.

  6. #6
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Simple. Using any AJAX would be simple, along with XML, PHP, possibly JavaScript. But there should be some sort of server involved.

    -magicyte

  7. #7
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,040
    Thanks
    16
    Thanked 318 Times in 316 Posts
    Blog Entries
    14

    Default

    I found this download and its very useful but I would like to adapt it further and need some help.

    I've edited the save.php file with a code snippet to work with php4 but I dont really know that much about php to adapt the script to work on an editable area within the index.php page itself rather than reading and changing content in an external contents.txt file.

    So, I'd like to edit an editable div in index.php and save it to index.php (not the external contents.txt file)
    It also needs to be compatiable with php4

    Can anybody offer any coding assistance please?

    Thanks

  8. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,040
    Thanks
    16
    Thanked 318 Times in 316 Posts
    Blog Entries
    14

    Default

    Ok - I've done some more Googling and come across this code which might be an alternative to the editor429_v2.zip download above. (The edito429 script is my first choice but the code below also does a similar job and I'm sure could be adapted to my needs)

    Code is here: http://codingforums.com/showthread.php?p=768811

    Example editable page is here: http://edit.awardspace.co.uk/

    The problem is at the moment, when you go into edit mode, you can see and edit all the html tags - what I would really like is for the edit page to just show the content as defined within an editable area rather than the whole web page structure.

    I have no idea how to adapt the code to target and pluck out the contents of a named div for example so if somebody could offer some assistance, I would be very grateful.

    Thanks
    Last edited by Beverleyh; 07-22-2009 at 10:34 AM. Reason: additional information added

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •