View Full Version : POSTing values from autocomplete in a form for entering into a db

01-24-2012, 05:56 AM
I have a JQuery autosuggest working properly on my form.php page... Now I want to get my form to actual POST the input values. So currently if I just run search.php, I get the following (using echo json_encode):

{"label":"Henry Gale","value":"henrygale@gmail.com"},{"label":"Amy Gerges","value":"amy@yahoo.com"}, and the list goes on.

So since the search is working properly. Now, I want to POST only the values that I place in the form's input field. I currently have:

$(document).ready(function() {
$( "#autocomp" ).autoSuggest("search.php", {
minChars: 2,
selectedItemProp: "label",
searchObjProps: "label",
selectedValuesProp: "value",
selectionLimit: 8,
formatList: function(data, elem){
var my_image = data.image ;
var my_label = data.label;
var new_elem = elem.html(my_image + my_label);
return new_elem;

<input name="contacts" type="text" id="autocomp" maxlength="35" />

But if I do an echo of the $_POST['contacts'] I just get the word: Array

I am doing something wrong, just not sure what... Since my input gets a list of comma separated values, how can I:

1) make sure the input values get the "value" attribute which corresponds to the emails.
2) post the emails so I can do things with the emails (run them through format checks, insert them into a mysql db, etc).