如何获取jquery自动完成值而不是标签? 如果我添加依赖自动完成,还指导我?

How to take values instead of taking labels

I'm getting names but I want there values like "ActionScript" value is 1 "AppleScript" value is 2

As well as guide me if I add dependence autoselect, below is my code

<?php 
if(isset($_POST) && !empty($_POST))
{
    print_r($_POST);
}
?>    
<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>jQuery UI Autocomplete - Default functionality</title>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script>
      $( function() {
        var availableTags = [
          "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>
    <form action="" method="POST"> 
    <div class="ui-widget">
      <label for="tags">Tags: </label>
      <input id="tags" name="tags">
    </div>
    <input type="submit" name="submit">
    </form>


</body>
</html>

PHPFiddle

You can define a select callback, get the chosen value, get the source list and fetch the index of the selected item in the list:

 $( function() {
        var availableTags = [
          "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,
          select: function (event, ui) {
            event.preventDefault();
            var source = $( "#tags" ).autocomplete("option", "source" );
            var value = ui.item.value;
            $(this).val(source.indexOf(value)+1);
            // console.log(source.indexOf(value)+1, $(this));
          }
        });
      } );
<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>jQuery UI Autocomplete - Default functionality</title>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

    </head>
    <body>
    <form action="" method="POST"> 
    <div class="ui-widget">
      <label for="tags">Tags: </label>
      <input id="tags" name="tags">
    </div>
    <input type="submit" name="submit">
    </form>


</body>
</html>

</div>