Update Div Based on Textbox Entry

Discussion in 'Web Design and Development' started by Vitaminwater, Sep 17, 2010.

  1. Vitaminwater macrumors newbie

    Joined:
    Aug 18, 2009
    #1
    Good Afternoon All,

    Currently I am trying to create a form that requires user input in the form of a postal code (ie 06515, 95010 etc). I currently have a database full of zipcodes, their associated state name, and lots of other information about it.

    I'm trying to set up my form so that when a user enters a certain zipcode say, 06515, some text appears next to the textbox containing the correct information from the database.

    Thanks for your help!
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Well you'll add an event handler for maybe the onblur event for the text field, then use AJAX to connect server side and query the DB, and return the info and place it where you want on the page.

    How much JavaScript do you know? You likely won't be able to find a pre-built solution so you will need to know JavaScript and a server side language like PHP for interacting with the DB. So what specifically do you need help with?
     
  3. Vitaminwater thread starter macrumors newbie

    Joined:
    Aug 18, 2009
    #3
    Thanks for the response.

    I'm all set with communicating with my mysql db using php. I know some light javascript, but where I start to lose traction is setting up the ajax to work with the mysql php code.

    Any help is appreciated. Thanks!
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    If you're new to AJAX you may want to use a JavaScript library, which has AJAX functions built in for easy use. Here's jQuery's AJAX API. Here's a page for Dojo's. Most of the JavaScript libraries have a AJAX interface. I even have one.
     

Share This Page