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

    Help with dropdown

    I am writing php code to select data via a dropdown list from a mysql table of materials for a transaction log. I want to be able to insert a new material if it is not in the dropdown list. How can this be done without leaving the page, inserting a new record, returning to the page, refreshing the page to repopulate the dropdown?

    Do I need to use js? or can this be done with php?

    This seems like a situation which I would think many programmers have a need for.

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    254
    Thanks
    1
    Thanked 63 Times in 63 Posts
    It can be done using php but if you don't want to have to "refresh" a page, you can use AJAX or any of the javascript libraries to achieve that.
    Example using jQuery

  • Users who have thanked shadowmaniac for this post:

    jvernice (11-05-2009)

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can understand the desire to "not leave" the current page. Your situation is exactly what Ajax techniques were developed for.

    PHP script happens at the server and results in data that is sent to the client.
    Javascript happens at the client after the server sends the script code there.

    Ajax, not being a 'language' but a technique, is all about using JS on the client,after to reach back to the server for additional information. When the ajax object gets an answer back from the server, JS reads the response and uses it to update the page.


  •  

    Posting Permissions

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