SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto Update Form As User Inputs Fields

    Hi, I have a form that I would like to auto-update/populate fields based on a uses input into another field. For example, I have a MySQL table with user groups and users. If the user selects a group from the drop down group selection I would like to auto update the users drop down (which starts off with all users) to just include the users of the selected group. If the user selects a user I would like to auto-update the group field. My tables are below.
    Code:
    User Table
    -----------------------------------------------
    | user_id     | user_name         | group_id  |
    -----------------------------------------------
    | 1           | Chris             | 1         |
    | 2           | John              | 1         |
    | 3           | Jim               | 1         |
    | 4           | Steve             | 1         |
    | 5           | Dennis            | 2         |
    | 6           | Brad              | 2         |
    | 7           | Jeremy            | 2         |
    | 8           | Brian             | 2         |
    -----------------------------------------------
    
    Group Table
    --------------------------------------
    | group_id     | group_name          |
    --------------------------------------
    | 1            | Managers            |
    | 2            | Engineers           |
    --------------------------------------
    Standard PHP to create the drop down lists I am fine with but I'm not sure how to auto-update or populate the fields as the user makes their way through the form.

    Thanks for any help or pointers.

    Chris

  2. #2
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for this you need to use Javascript, Check out Jquery's awesome form management tools, written in Javasript for your enjoyment, they have all the solutions you need.
    http://www,jquery.com

  3. #3
    SitePoint Zealot Sogo7's Avatar
    Join Date
    May 2011
    Posts
    129
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I use the jquery autocomplete over at the jobs section on Lovelogic.net, it's a mix of Ajax & PHP querying the database and works rather nicely. Even has a spinny waiting image while running big queries of the database.
    Lovelogic.net Personal Projects Pit - Spammers welcome

  4. #4
    Non-Member
    Join Date
    Jun 2012
    Posts
    88
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PolyPlanker View Post
    Standard PHP to create the drop down lists I am fine with but I'm not sure how to auto-update or populate the fields as the user makes their way through the form.

    Thanks for any help or pointers.
    If you want to auto-update without a page refresh then you will need AJAX. Here's a good tutorial.

    If you use jquery (which is just javascript btw) you will end up running a lot more javascript in the background than if you build your own ajax functionality.


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
  •