Results 1 to 3 of 3

Thread: Suggestion box

  1. #1
    Join Date
    Mar 2003
    Somewhere on Planet Earth, I hope.

    Suggestion box

    Hi there! I hope you can help me out please.

    I have a private messaging system we custom coded, and to select who the message is addressed to we have a select menu with a list of all users names which we fetch from mysql via PHP.

    Because we allow more than one recipient, we actually have 10 select menus with all the names and hide some of them with javascript so that they only show up if the sender wants to submit to more than one person.

    This works, but is a really messy option.

    What I've been trying to work on (and downloading zip files which seem really overkill) and had very little success is to create a Javascript where we can put an array of names from PHP (this I can do no problem) and then have one input box where the sender can start typing a few letters of the name, and suggestions come up a little bit like on Facebook!

    I was wondering if anyone has a solution such of this that they could possibly share? I would also need it to only allow 10 selections max (although we do check this with PHP too). A perfect example of this is the facebook private messaging thing, where it lets you put the names you want to send the message to in one box.

    Hope this makes sense, and looking forward to your reply. I will really appreciate any help.

  2. #2
    Join Date
    Mar 2003
    Somewhere on Planet Earth, I hope.
    Any ideas? Thank you

  3. #3
    Join Date
    Mar 2010
    Another way you could do it is to use AJAX to get your name suggestions.

    Maybe something like the following:

    1) set up an input textbox in which the user can type parts of a name.

    2) set up a select list whose options will be populated by the returned response from an ajax function.

    3) set up a button labled something like "Get names" that when clicked will run an ajax function.

    4) The Ajax function would send the current value in the textbox to a php script to query the db for names containing the textbox value.

    $seed = $_POST['txtValue'];
    $query = 'select fldName from tblUsers where fldName like "'.$seed.'"';
    and then use the returned results to write your <options> and return them to the browser in the select list

    Anyway, just food for thought...
    Last edited by tirna; 04-18-2010 at 02:11 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles