1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Ajax + Php

Discussion in 'PHP' started by PET, Nov 6, 2008.

  1. #1
    Hello there,

    this is pretty basic ajax but I'm still not good at it. I found some tutorials however many of them don't explain stuff and also I need a different thing.

    I have a form.
    I type something in a search box.
    I pick something from that "auto-suggest".
    When I click that something from the list I have 2 fields that get populated. ID + name
    (this part is already done)

    However, when that 2 fields are populated I want to make a PHP Query and check if that ID is already in my database. After I check it, if the product is in the database I want to echo a message in a specific DIV.

    Also, how do I call that function since the field is automaticly populated and not typed. I don't know if "onkeyup" works.

    Any suggestions? I know I have to send the detail with POST, but I don't know exactly how, and also I don't know how to populate a DIV with the message.
     
    PET, Nov 6, 2008 IP
  2. garrettheel

    garrettheel Peon

    Messages:
    341
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I suggest the use of jQuery to do this, it'll make it a lot easier. Don't have the time to baby you through the whole thing at the moment, just google jquery and read some tutorials
     
    garrettheel, Nov 6, 2008 IP
  3. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I don't want to use other scripts. I just want to LEARN to do this right.
     
    PET, Nov 6, 2008 IP
  4. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    jquery is a great js library, but if you want to do it the old fashioned way, googling is the best way to learn :)
     
    shineDarkly, Nov 6, 2008 IP
  5. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #5
    go with jquery as garrettheel told u , if u dont know what jquery is ... http://jquery.com/


    it's not a script , and its not magic ... u need to write code but it save you a lot of time , instead of writing 100 lines it will take few ...
     
    commandos, Nov 6, 2008 IP
    shineDarkly likes this.
  6. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    well said sir, but i think he want to go with pure js without any help from libraries so it's all up to the OP's discretion
     
    shineDarkly, Nov 6, 2008 IP