SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot ricklach's Avatar
    Join Date
    Nov 2004
    Location
    Victoria BC
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Filling in a Form with AJAX

    I am looking for a little advice/guidance in this question. Imagine a form with organizational address information on it. To this form I want to add names (and ids) and job positions in an iterative fashion (ie. add names and positions until the form is complete) and of course store the organization id, person_id and other data in a table.

    To tackle this task I have a form with the basic organizational data and a link to a popup to add names and position information. In the popup, I was going to add some AJAX autocomplete to find the name information and add the position info from a dropdown box. However, there is a possibility that the name I am looking for will not be in the database and so I will need to add a new person first and then go back and and start the process all over. Does this sound like a reasonable approach or are there suggestions for a better way of doing this task.

    Rick
    Ruby, Ruby when will you be mine

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello again Rick,

    Please excuse my response if I am incorrect because I am having a difficult time understanding what you are trying to do. If I understand correctly here is how I see it:

    You have a list of names and on a page you want to add people from that list (basically, without the extra data). So you have a popup window to add them, and you have a dropdown to select the person and then enter various information about them and add them to the list. You want to know how to handle adding NEW names without starting this entire list over.

    Well one thing you could do, maybe, if I am understanding correctly, is create an ajax text_field autocompletion thing. Sorry, I mean an autocompletion text field. What this does is after typing in three or more (configurable) letters, it calls an action in your controller asking for data starting with that or containing that. You return an array and it creates a div that "drops down" below it that youcan choose from, like Google Suggest. However, if the name doesn't exist, the person can just type in the new name and you can save it then and there. They don't need to start the whole list over.

    I feel like I have misunderstood you and I apologize beforehand if that is the case.

    Mitch
    Happy switcher to OS X running on a MacBook Pro.

    Zend Certified Engineer

  3. #3
    SitePoint Zealot ricklach's Avatar
    Join Date
    Nov 2004
    Location
    Victoria BC
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mitch,
    You more or less have it correct. The application I am building is built on the premise that the data for people already exists and so in this case a lookup/autofind will work just fine. However, there are always going to be cases where the person is not defined (that is all the fields related to a person and their residence) and in those cases if you cannot find the lookup person you will have to create the new person first and then go back and do the lookup.

    So I have the details of an organization in another table and the employees of that organization in yet another table (all foreign key fields for the most part). From a new organization the user can add a new employee - a popup with a lookup field finds the employee and completes the rest of the employee job-specific fields and saves the record. That closes the popup and refreshes the organization screen and adds the newly selected employee to a table on the org screen. If the employee is not in the lookup then I have to create the new employee first and then go back to the org screen to add the new employee from the popup. I can probably devise a variable that will return me to the originating screen after I create the new person (I almost feel like Dr Frankenstein when it comes to creating new people).

    I intend to use this methodology in a number of places so it is imperative that I get the building blocks correct the first time.

    Rick
    Ruby, Ruby when will you be mine


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
  •