PHP / jQuery - Instant Editable Fields

Discussion in 'PHP' started by theextelligence, Dec 10, 2009.

  1. #1
    Hi,

    I was looking for a solution (using php/jquery) similar to the one as shown in the screen shot.

    I have a user database with 3 fields:

    id (auto number)
    name (varchar)
    email (varchar)

    the user lists gets populated in a grid (html table), clicking on either the name or the email address would convert the label into an editable text box and after editing once i remove the cursor from the textbox, the data gets saved in the database.

    Any help with a code snippet will be highly appreciated.

    Thanks


    [​IMG]
     
    theextelligence, Dec 10, 2009 IP
  2. aquilax

    aquilax Member

    Messages:
    126
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #2
    Try this:

    <style>
      input{border:none}
      input:focus{border:1px solid black}
    </style>
    <input name="e1" value="test name" onblur="senddata(this)">
    Code (markup):
     
    aquilax, Dec 10, 2009 IP
  3. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #3
    You'll probably also want something like this (pseudocode):

    function fieldswitch(this)
    {
          this.innerHTML = '<input name="e1" value="test name" onblur="senddata(this)">';
    }
    
    <div id="input_name" onclick="fieldswitch(this)">John Smith</div>
    HTML:
     
    Wogan, Dec 11, 2009 IP
  4. theextelligence

    theextelligence Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    Thanks for the help :)
     
    theextelligence, Dec 11, 2009 IP