auto complete

iamkevinjohnson pro asked 8 years ago

var states = ["Alabama","Alaska","Arizona","Arkansas","California"]; In addition to state name, I need hidden corresponding value/code for each state? For example: AL, AK, AZ, AR, CA. Looking for an example. Thanks
Hello Iamkevinjohnson, Here you have an example of how to add additional value to choices.
var states = [
    "Alabana",
    "Alaska",
    "Arizona",
    "Arkansas",
    "California"
];
var data = [
    "Al",
    "Ak",
    "Ar",
    "Ark",
    "Cal"
]

$('.mdb-autocomplete').mdb_autocomplete({
    data: states
});

$('.mdb-autocomplete').on('mouseenter', function() {
    var index = jQuery.inArray($(this).val(), states);
        $(this).attr("data-value", data[index])
        console.log($(this).attr("data-value"));
})
Regards, Adrian

iamkevinjohnson pro answered 8 years ago

Thanks!
Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No