Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2012, 05:56 AM   PM User | #1
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
POSTing values from autocomplete in a form for entering into a db

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:

Code:
<script>
	$(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;
			}
		});
	});
</script>

<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).
Juniper747 is offline   Reply With Quote
Reply

Bookmarks

Tags
autocomplete, autosuggest, jquery, json, mysql

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:14 AM.


Advertisement
Log in to turn off these ads.