Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    autocomplete, php, and mysql


    I hope you can help me! I had posted a question to the php forum that a responder had suggested should go in this forum. I know nothing abt ajax (though I have some javascript experience from what seems to be another lifetime ago), so I apologize if I sound completely clueless.

    My question:
    I am working on a form tracking courses to a professor. The code I have written now allows me to pull up any existing courses entered into the database into a dropdown menu. The user can select an existing course or, if the course doesn't exist, hop on over to another field an add a course to the database.

    Is there a way I can streamline this so that I can select and add in the same field? I've been looking at bit at mentions of autocomplete, but I'm not sure if it is possible for each autocomplete suggestion to associate itself with the records in my mysql database and for it to create a new course record when the course is new?

    I don't need a code or anything, but if you could let me know if it's possible and maybe even point me in the right direction, it'd be great!

    Thank you so much!

  2. #2
    Senior Coder
    Join Date
    Apr 2011
    London, England
    Thanked 354 Times in 353 Posts
    It is possible to do this and it's called a 'combo box'. Ajax can be used to send the new course title back to the database to be added. So it's a combination of

    PHP to populate the page and the select list
    JavaScript or Ajax to AutoComplete the user's selection
    JavaScript to handle when they type a new course title
    Ajax to send the new title to the server
    PHP to receive and store this new value in the database.

    If you search for 'JavaScript combo box' you will find a number of scripts, but finding one that combines all these steps might be trickier.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  3. Users who have thanked AndrewGSW for this post:

    mingqi (06-13-2011)


Posting Permissions

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