SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Standard practices with auto-completing form fields?

    I have a data that involves text and an index number from the database, and it is the index number that is used when the form is submitted, but, populating the text field with the index number is not user friendly.

    So, let's say I have a customer name "Fred" (the text), and in the database, Fred's customer id number is 2.

    I type in "F-r-e" and Fred pops up. I click it, and...

    With an auto-complete, the text should fill in the text field, but where do you put the database index number that points to the record from which the text is taken, or that you want to manipulate?

    Do you put it in a hidden field, and then when the form is submitted, use the hidden field, ignoring the text field?
    Do you create a custom attribute in the text field input where you place the index number?
    John

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by PHP John View Post
    Do you put it in a hidden field, and then when the form is submitted, use the hidden field, ignoring the text field?
    Yes, that's the best way.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Yes, that's the best way.
    Thank you!
    John


Tags for this Thread

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
  •