October 2009
M T W T F S S
    Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Categories

  • [+]ASP.NET (7) 
  • [+]C# (87) 
  • [+]C++ (13) 
  • [+]Delphi (20) 
  • [—]JavaScript (24) 
  • [+]Regular Expressions (7) 
  • [+]SQL (13) 
  • [+]VB (100) 
  • [+]VB.NET (4) 

Online

Users: 8 Guests
  • Loading...


    Loading...

    Login






    Register | Lost password?

    Register





    A password will be mailed to you.
    Log in | Lost password?

    Retrieve password





    A confirmation mail will be sent to your e-mail address.
    Log in | Register
  • A simple edit in place

    /*
       Author: Snyke ( http://www.Snyke.net )
       Description: In-Situ Editing of text paragraphs on click.
       Based on 'Edit-in-Place with Ajax' of 24ways.org
       @params string element, parameters (get)
    
       -------
       Note :
       -------
       This code require Prototype JavaScript Framework [ http://prototype.conio.net/ ]
       Which is also included in this library
    */
    
    function editinplace(obj, params)
    {
            Element.hide(obj);
            var textarea = '<div id="' + obj.id +
                '_editor"><textarea class="editable" id="' + obj.id +
                '_edit" name="' + obj.id + '" rows="4" cols="60">' +
                obj.innerHTML + '</textarea>';
            var button = '<div><input id="' + obj.id +
                         '_save" type="button" value="Save" /> <input id="' +
                         obj.id + '_cancel" type="button" value="Cancel" /></div></div>';
            new Insertion.After(obj, textarea + button);
            Event.observe(obj.id + '_save', 'click', function(){saveChanges(obj, params)}, false);
            Event.observe(obj.id + '_cancel', 'click', function(){cleanUp(obj)}, false);
    }
    
    function saveChanges(obj, params)
    {
            var new_content =  escape($F(obj.id + '_edit'));
            obj.innerHTML   = "<img src='thm/img/loading.gif'> Saving...";
    
            cleanUp(obj, true);
    
            var success     = function(t){editComplete(t, obj);}
            var failure     = function(t){editFailed(t, obj);}
            var url         = 'index.php';
            var pars        = '&' + params + '&ajax=editinplace&id=' + obj.id + '&content=' + new_content;
            var myAjax      = new Ajax.Request(url, {method:'post', postBody:pars, onSuccess:success, onFailure:failure});
    }
    
    function cleanUp(obj, keepEditable)
    {
            Element.remove(obj.id+'_editor');
            Element.show(obj);
            //new Effect.Highlight(obj, { duration: 3.0 });
    }
    
    function editComplete(t, obj)
    {
            obj.innerHTML   = t.responseText;
    }
    
    function editFailed(t, obj)
    {
            obj.innerHTML   = 'Could not save...';
            cleanUp(obj);
    }
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Leave a Reply

     

     

     

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">

    Spam Protection by WP-SpamFree Plugin