选择表单值并从数据库返回唯一ID

I have an ajax search form field returning an address value from the database. I am trying to get the unique id of a selected address and display that value on a div called "demo". Any ideas?

<script>
        function myFunction() {
        var x = document.getElementById("ls_query");
        var adr = x.value;
        document.getElementById("demo").innerHTML = "address is:" +adr;

        }
    </script>

ls_query value is an address (123 whatever the street name...) lets say the unique ID is '5'. I need value 5 returned instead of the address.