AUTOCOMPLETE JQUERY

personal

to using the jquery autocomplete to make a very cool because the jquery, but I have a problem to feed the variable responsible to fill the autocomplete wipe down my script where I am wrong? I'm putting in an array.

var availableTags = <?php echo $arr; ?>

Am I doing wrong?

<?php

$a = mysql_connect("127.0.0.1","root","");
$b = mysql_select_db("erp2");


$sql = mysql_query("SELECT VENCIMENTO FROM conta");

while($resposta = mysql_fetch_array($sql)){

	$arr[] =  $resposta['VENCIMENTO'];

}

?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>jQuery UI Autocomplete - Default functionality</title>
	<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
	<script src="../../jquery-1.6.2.js"></script>
	<script src="../../ui/jquery.ui.core.js"></script>
	<script src="../../ui/jquery.ui.widget.js"></script>
	<script src="../../ui/jquery.ui.position.js"></script>
	<script src="../../ui/jquery.ui.autocomplete.js"></script>
	<link rel="stylesheet" href="../demos.css">
	<script>
	$(function() {
		var availableTags = <?php echo $arr; ?>
			/*"ActionScript",
			"AppleScript",
			"Asp",
			"BASIC",
			"C",
			"C++",
			"Clojure",
			"COBOL",
			"ColdFusion",
			"Erlang",
			"Fortran",
			"Groovy",
			"Haskell",
			"Java",
			"JavaScript",
			"Lisp",
			"Perl",
			"PHP",
			"Python",
			"Ruby",
			"Scala",
			"Scheme"*/
										
		$( "#tags" ).autocomplete({
			source: availableTags
		});
	});
	</script>
</head>
<body>
	
<div class="demo">

<div class="ui-widget">
	<label for="tags">Tags: </label>
	<input id="tags" />
</div>

</div><!-- End demo -->



<div class="demo-description">
<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try.</p>
<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p>
</div><!-- End demo-description -->

</body>
</html>

Open in new window

eduardo12foxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

varontronCommented:
The key 'source' takes an array as an argument, as you know, but it must be in the proper syntax.

If you look at the documentation here: http://docs.jquery.com/UI/Autocomplete

You'll see an example like this:

$("input#autocomplete").autocomplete({
    source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
});

Open in new window


Notice the square brackets, and quoted strings.  Make sure the "array" you return from php is in the proper syntax to be a JSON array.  It may be necessary to iterate over the array in php and build a new JSON string array dynamically, rather than just assign the variable.
0
leakim971PluritechnicianCommented:
>Am I doing wrong?
right click on your page, locate the line, what do you see?

what about : http://php.net/manual/en/function.implode.php
var availableTags = [<?php implode(",", $arr); ?>]

Open in new window

0
eduardo12foxAuthor Commented:
Guys

Guys I did this:

      <script>
      $(function() {
            var availableTags = [<?php implode(",", $arr); ?>]
              /*"ActionScript",
                  "AppleScript",
                  "Asp",
                  "BASIC",
                  "C",
                  "C++",
                  "Clojure",
                  "COBOL",
                  "ColdFusion",
                  "Erlang",
                  "Fortran",
                  "Groovy",
                  "Haskell",
                  "Java",
                  "JavaScript",
                  "Lisp",
                  "Perl",
                  "PHP",
                  "Python",
                  "Ruby",
                  "Scala",
                  "Scheme"*/
                                                            
            $( "#tags" ).autocomplete({source: ["php"]});
      });
      </script>

But did not solve!  =P
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

eduardo12foxAuthor Commented:
I posted the complete code, the file is in development-bundle> test.php

suddenly if you guys can do a test at a local bank vcs
Jquery.zip
0
varontronCommented:
It could be that your script is running before the dom is finished loading.  Try this:

$(document).ready(function() {
            var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                            
            $( "#tags" ).autocomplete({source: ["php"]});
      });

Open in new window


Also note the semicolon at the end of the availableTags declaration.
0
leakim971PluritechnicianCommented:
           var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                           
            $( "#tags" ).autocomplete({source: availableTags});
0
eduardo12foxAuthor Commented:
I put both ways but none worked:

<script>
      $(function() {
            $(document).ready(
            function() {
            var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                           
            $( "#tags" ).autocomplete({source: ["php"]});
      });
      });
      </script>
0
leakim971PluritechnicianCommented:
var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                           
            $( "#tags" ).autocomplete({source: availableTags});
0
eduardo12foxAuthor Commented:
Not!

<script>
      var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                           
            $( "#tags" ).autocomplete({source: availableTags});
      </script>
0
eduardo12foxAuthor Commented:
you tested the code I sent in attachment? On your local server work?
0
leakim971PluritechnicianCommented:
Please answer : right click on your page, locate the line, what do you see?

or post the code here
0
eduardo12foxAuthor Commented:
I see...


<!DOCTYPE html>

<html lang="en">

<head>

      <meta charset="utf-8">

      <title>jQuery UI Autocomplete - Default functionality</title>

      <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">

      <script src="../../jquery-1.6.2.js"></script>

      <script src="../../ui/jquery.ui.core.js"></script>

      <script src="../../ui/jquery.ui.widget.js"></script>

      <script src="../../ui/jquery.ui.position.js"></script>

      <script src="../../ui/jquery.ui.autocomplete.js"></script>

      <link rel="stylesheet" href="../demos.css">

      <script>

      var availableTags = [];

              /*...*/

                                                           

            $( "#tags" ).autocomplete({source: ["php"]});

      </script>

</head>

<body>

      

<div class="demo">



<div class="ui-widget">

      <label for="tags">Tags: </label>

      <input id="tags" />

</div>



</div><!-- End demo -->







<div class="demo-description">

<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try.</p>

<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p>

</div><!-- End demo-description -->



</body>

</html>
0
eduardo12foxAuthor Commented:
When I put  echo in code this:

var availableTags = [<?php echo implode(",", $arr); ?>];

My source code page:
 
<!DOCTYPE html>

<html lang="en">

<head>

	<meta charset="utf-8">

	<title>jQuery UI Autocomplete - Default functionality</title>

	<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">

	<script src="../../jquery-1.6.2.js"></script>

	<script src="../../ui/jquery.ui.core.js"></script>

	<script src="../../ui/jquery.ui.widget.js"></script>

	<script src="../../ui/jquery.ui.position.js"></script>

	<script src="../../ui/jquery.ui.autocomplete.js"></script>

	<link rel="stylesheet" href="../demos.css">

	<script>

	var availableTags = [2010-10-10,2011-01-18,2011-01-22,2011-01-01,2011-01-15,2011-01-22,2011-01-22,2011-01-21,2011-01-21,2011-01-21,2011-01-30,2011-01-01,2011-01-29,2010-12-02,0000-00-00,2011-01-01,2011-01-01,2011-01-01,2011-12-01,2010-10-05,2010-10-07,2011-01-02,2011-01-02,2011-01-03,2011-01-03,2011-01-03,2011-01-03,2011-12-03,2011-01-03,2011-01-03,2011-01-03,2010-12-31,2010-12-31,2010-12-31,2010-12-31,2010-12-31,2010-12-31,2011-01-03,2011-01-04,2011-01-04,2011-01-18,2011-01-04,2011-01-04,2011-01-04,2011-01-04,2011-01-05,2011-01-05,2011-01-05,2011-01-05,2011-01-05,2011-01-05,2011-02-05,2011-03-05,2011-04-05,2011-05-05,2011-06-05,2011-07-05,2011-08-05,2010-12-16,2011-01-05,2011-01-05,2011-01-05,2011-01-06,2011-01-06,2011-02-06,2011-03-06,2011-04-06,2011-05-06,2011-06-06,2011-07-06,2011-08-06,2011-09-06,2011-10-06,2011-11-06,2011-12-06,2011-01-05,2011-02-05,2011-03-05,2011-04-05,2011-05-05,2011-06-05,2011-07-05,2011-08-05,2011-09-05,2011-01-06,2011-01-06,2011-01-06,2011-12-06,2011-12-06,2011-12-06,2011-12-06,2011-01-06,2011-12-06,2011-01-07,2011-12-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-02-07,2011-03-07,2011-01-07,2011-01-22,2011-01-07,2011-02-07,2011-01-07,2011-01-07,2011-01-07,2011-01-21,2011-01-08,2011-01-09,2011-01-09,2011-02-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-11,2011-01-11,2011-02-11,2011-03-11,2011-04-11,2011-05-11,2011-06-11,2011-07-11,2011-07-11,2011-08-11,2011-09-11,2011-10-11,2011-11-11,2011-12-11,2012-01-11,2012-02-10,2012-03-11,2012-04-11,2012-05-11,2012-06-10,2012-07-10,2012-08-10,2012-09-10,2012-10-10,2012-11-10,2012-12-10,2013-01-01,2011-02-03,2011-02-07,2011-02-07,2011-02-09,2011-02-11,2011-02-14,2011-02-15,2011-02-17,2011-02-21,2011-02-21,2011-02-23,2011-01-11,2011-01-18,2011-01-25,2011-01-11,2011-01-11,2011-01-11,2011-01-11,2011-01-12,2011-01-12,2011-01-12,2011-01-12,2011-01-12,2011-02-12,2011-03-12,2011-01-12,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-15,2011-01-15,2011-02-15,2011-03-15,2011-01-15,2011-01-15,2011-01-15,2011-01-15,2010-01-15,2011-01-15,2011-01-22,2011-01-15,2011-02-15,2011-03-15,2011-01-16,2011-01-16,2011-01-17,2011-02-17,2011-03-17,2011-04-17,2011-05-17,2011-06-17,2011-07-17,2011-08-17,2011-09-17,2011-10-17,2011-11-17,2011-12-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-02-17,2011-03-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-18,2011-01-18,2011-01-25,2011-01-18,2011-01-25,2011-01-18,2011-01-18,2011-02-18,2011-01-18,2011-01-18,2011-01-18,2011-01-19,2011-02-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-02-19,2011-01-19,2011-02-19,2011-01-19,2011-02-19,2011-01-19,2011-01-19,2011-02-19,2011-01-19,2011-02-03,2011-01-19,2011-01-20,2011-02-19,2011-01-20,2011-02-20,2011-03-20,2011-04-20,2011-05-20,2011-06-20,2011-07-20,2011-08-20,2011-09-20,2011-10-20,2011-11-20,2011-12-20,2012-01-20,2012-02-20,2012-03-20,2012-04-20,2012-05-20,2012-06-20,2012-07-20,2011-08-20,2012-09-20,2012-10-20,2011-02-04,2011-02-07,2011-02-08,2011-02-10,2011-02-14,2011-02-14,2011-02-16,2011-02-18,2011-02-21,2011-02-22,2011-02-24,2011-02-28,2011-02-28,2011-03-02,2011-03-04,2011-03-07,2011-03-08,2011-03-10,2011-03-14,2011-03-14,2011-03-16,2011-03-18,2011-03-21,2011-03-22,2011-03-24,2011-03-28,2011-01-16,2011-01-27,2011-02-28,2011-03-28,2011-01-28,2011-03-10,2011-03-24,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-24,2011-02-11,2011-01-24,2011-02-11,2011-01-24,2011-02-11,2011-01-24,2011-02-11,2011-01-28,2011-02-17,2011-01-28,2011-02-17,2011-01-31,2011-02-21,2011-01-24,2011-01-31,2011-04-19,2011-04-15,2011-04-14,2011-04-04,2011-04-12,2011-04-12,2011-04-12,2011-04-26,2011-03-28,2011-04-26,2011-03-31,2011-10-01];

              /*...*/

                                                            

            $( "#tags" ).autocomplete({source: ["php"]});

	</script>

</head>

<body>

	

<div class="demo">



<div class="ui-widget">

	<label for="tags">Tags: </label>

	<input id="tags" />

</div>



</div><!-- End demo -->







<div class="demo-description">

<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try.</p>

<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p>

</div><!-- End demo-description -->



</body>

</html>

Open in new window

0
eduardo12foxAuthor Commented:
Whait i put Online Give me two minutes
0
leakim971PluritechnicianCommented:
>Whait i put Online Give me two minutes

Not needed, ID:37057647, check your line 27 :


var availableTags = [2010-10-10,2011-01-18,2011-01-22,2011-01-01,2011-01-15,2011-01-22,2011-01-22,2011-01-21,2011-01-21,2011-01-21,2011-01-30,2011-01-01,2011-01-29,2010-12-02,0000-00-00,2011-01-01,2011-01-01,2011-01-01,2011-12-01,2010-10-05,2010-10-07,2011-01-02,2011-01-02,2011-01-03,2011-01-03,2011-01-03,2011-01-03,2011-12-03,2011-01-03,2011-01-03,2011-01-03,2010-12-31,2010-12-31,2010-12-31,2010-12-31,2010-12-31,2010-12-31,2011-01-03,2011-01-04,2011-01-04,2011-01-18,2011-01-04,2011-01-04,2011-01-04,2011-01-04,2011-01-05,2011-01-05,2011-01-05,2011-01-05,2011-01-05,2011-01-05,2011-02-05,2011-03-05,2011-04-05,2011-05-05,2011-06-05,2011-07-05,2011-08-05,2010-12-16,2011-01-05,2011-01-05,2011-01-05,2011-01-06,2011-01-06,2011-02-06,2011-03-06,2011-04-06,2011-05-06,2011-06-06,2011-07-06,2011-08-06,2011-09-06,2011-10-06,2011-11-06,2011-12-06,2011-01-05,2011-02-05,2011-03-05,2011-04-05,2011-05-05,2011-06-05,2011-07-05,2011-08-05,2011-09-05,2011-01-06,2011-01-06,2011-01-06,2011-12-06,2011-12-06,2011-12-06,2011-12-06,2011-01-06,2011-12-06,2011-01-07,2011-12-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-01-07,2011-02-07,2011-03-07,2011-01-07,2011-01-22,2011-01-07,2011-02-07,2011-01-07,2011-01-07,2011-01-07,2011-01-21,2011-01-08,2011-01-09,2011-01-09,2011-02-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-10,2011-01-11,2011-01-11,2011-02-11,2011-03-11,2011-04-11,2011-05-11,2011-06-11,2011-07-11,2011-07-11,2011-08-11,2011-09-11,2011-10-11,2011-11-11,2011-12-11,2012-01-11,2012-02-10,2012-03-11,2012-04-11,2012-05-11,2012-06-10,2012-07-10,2012-08-10,2012-09-10,2012-10-10,2012-11-10,2012-12-10,2013-01-01,2011-02-03,2011-02-07,2011-02-07,2011-02-09,2011-02-11,2011-02-14,2011-02-15,2011-02-17,2011-02-21,2011-02-21,2011-02-23,2011-01-11,2011-01-18,2011-01-25,2011-01-11,2011-01-11,2011-01-11,2011-01-11,2011-01-12,2011-01-12,2011-01-12,2011-01-12,2011-01-12,2011-02-12,2011-03-12,2011-01-12,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-13,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-14,2011-01-15,2011-01-15,2011-02-15,2011-03-15,2011-01-15,2011-01-15,2011-01-15,2011-01-15,2010-01-15,2011-01-15,2011-01-22,2011-01-15,2011-02-15,2011-03-15,2011-01-16,2011-01-16,2011-01-17,2011-02-17,2011-03-17,2011-04-17,2011-05-17,2011-06-17,2011-07-17,2011-08-17,2011-09-17,2011-10-17,2011-11-17,2011-12-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-02-17,2011-03-17,2011-01-17,2011-01-17,2011-01-17,2011-01-17,2011-01-18,2011-01-18,2011-01-25,2011-01-18,2011-01-25,2011-01-18,2011-01-18,2011-02-18,2011-01-18,2011-01-18,2011-01-18,2011-01-19,2011-02-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-01-19,2011-02-19,2011-01-19,2011-02-19,2011-01-19,2011-02-19,2011-01-19,2011-01-19,2011-02-19,2011-01-19,2011-02-03,2011-01-19,2011-01-20,2011-02-19,2011-01-20,2011-02-20,2011-03-20,2011-04-20,2011-05-20,2011-06-20,2011-07-20,2011-08-20,2011-09-20,2011-10-20,2011-11-20,2011-12-20,2012-01-20,2012-02-20,2012-03-20,2012-04-20,2012-05-20,2012-06-20,2012-07-20,2011-08-20,2012-09-20,2012-10-20,2011-02-04,2011-02-07,2011-02-08,2011-02-10,2011-02-14,2011-02-14,2011-02-16,2011-02-18,2011-02-21,2011-02-22,2011-02-24,2011-02-28,2011-02-28,2011-03-02,2011-03-04,2011-03-07,2011-03-08,2011-03-10,2011-03-14,2011-03-14,2011-03-16,2011-03-18,2011-03-21,2011-03-22,2011-03-24,2011-03-28,2011-01-16,2011-01-27,2011-02-28,2011-03-28,2011-01-28,2011-03-10,2011-03-24,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-31,2011-03-02,2011-04-01,2011-05-02,2011-05-31,2011-06-30,0000-00-00,2011-08-29,2011-09-28,2011-10-28,2011-11-28,2011-01-24,2011-02-11,2011-01-24,2011-02-11,2011-01-24,2011-02-11,2011-01-24,2011-02-11,2011-01-28,2011-02-17,2011-01-28,2011-02-17,2011-01-31,2011-02-21,2011-01-24,2011-01-31,2011-04-19,2011-04-15,2011-04-14,2011-04-04,2011-04-12,2011-04-12,2011-04-12,2011-04-26,2011-03-28,2011-04-26,2011-03-31,2011-10-01];

Open in new window

0
leakim971PluritechnicianCommented:
I think you need to replace :

while($resposta = mysql_fetch_array($sql)){

      $arr[] =  $resposta['VENCIMENTO'];

}

by :

while($resposta = mysql_fetch_array($sql)){

      $arr[] =  '"' . $resposta['VENCIMENTO'] . '"';

}
0
eduardo12foxAuthor Commented:
dont work

$arr[] =  '"' . $resposta['VENCIMENTO'] . '"';
0
leakim971PluritechnicianCommented:
$( "#tags" ).autocomplete({source: availableTags});
0
leakim971PluritechnicianCommented:
work : $( "#tags" ).autocomplete({source: availableTags});
Clipboard02.jpg
0
leakim971PluritechnicianCommented:
CAN'T work : $( "#tags" ).autocomplete({source: ["php"]});
0
eduardo12foxAuthor Commented:
leakim971: Not solved!
0
eduardo12foxAuthor Commented:
leakim971:

you posted an image running in your browser is running the script?
0
leakim971PluritechnicianCommented:
$(document).ready(function() {

      var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                           
            $( "#tags" ).autocomplete({source: availableTags});

});
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
varontronCommented:
This is what you should try:
<script>
      $(document).ready(
            function() {
            var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                            
            $( "#tags" ).autocomplete({source:availableTags});
      });
      </script>

Open in new window


not this.
<script>
      $(function() {
            $(document).ready(
            function() {
            var availableTags = [<?php implode(",", $arr); ?>];
              /*...*/
                                                            
            $( "#tags" ).autocomplete({source: ["php"]});
      });
      });
      </script>

Open in new window


$(document).ready() is an event handler which fires when the dom completes.  if you wrap it in another function, it may be called before the dom loads, so your elements may not be available to alter.  
0
eduardo12foxAuthor Commented:
Thanks for help-me I need much this script, thanks!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.