SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript function

    I have a form which takes the Employee id as input.within the same form I have a field for employee name.
    the employee id and name are in the table called customer_info
    how do i enable a javascript function to take the input id entered to the database query and get the employee name to display in the text box

    thank you.
    kiran

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How much javascript do you know? To use js to query a database for information while the user is filling out a form requires advanced js techniques involving an XMLHttpRequest. You can certainly read all about it by searching for 'Ajax'.

  3. #3
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript runs on on the client, that is, in the users browser, not the server.
    The Javascript cannot directly access the servers databases under normal circumstances [exluding the use of ActiveX such as RDO, IMHO DO NOT go there!!]

    There are really two ways to do this:

    1. When the user enters the ID, have a button that posts the form to the server, which does the database lookup and returns to form populated with the details. This is the "old" standard way of doing things, but leaves the user experience lacking a bit.

    2. As 7stud said, use an AJAX query to perform the lookup in the background. This requires a semi-advance knowledge, but there are lots of libraries available, and its really not that complex. I have forms where the user types, and in response to the onkeyup event I set a timeout for about two seconds, if the user types again within the period, I start the timer again, if not, the system does a lookup in the background.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks - AJAX example

    Hey thanks guys,

    I have been using the first method of creating a button and having the form reposted.
    I needed futher information after seeing the result on another website. could you forward me info-examples about using the AJAX method.

    I appreciate the help.

    Kiran.


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
  •