/    Sign up×
Community /Pin to ProfileBookmark

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.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@DanUKauthorApr 18.2010 — Any ideas? Thank you ?
Copy linkTweet thisAlerts:
@tirnaApr 18.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.

[CODE]
$seed = $_POST['txtValue'];
$query = 'select fldName from tblUsers where fldName like "'.$seed.'"';
[/CODE]


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...
×

Success!

Help @DanUK spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...