Jquery or Javascript: Autocomplete from JSON for Multiple Form Fields -
i have form input text field of name 'building_n'; form has couple of hidden fields need populated external json file. currently, file text file info like:
[ { "buildingname":"building1", "floorplanlayer":"floorurl", "roomlayer": "roomurl", }, { "buildingname":"building1", "floorplanlayer":"floorurl", "roomlayer": "roomurl", } ]
i utilize either jquery or javascript allow users select 'buildingname' value , if select populate hidden fields 'floorplanlayer' , 'roomlayer' values.
i haven't found illustration allow me this. closest came using onkeyup event load json info , match via regular look didn't give users options select , selected first character match.
thanks!
take @ popular autocomplete library: https://github.com/devbridge/jquery-autocomplete
it's more robust traditional jquery ui's autocomplete. how step through problem using api provided library:
parse json file javascript object. build array of ofbuildingname
values. in autocomplete options, set lookup
attribute built array. set onselect
attribute callback function finds object related buildingname
selected , set hidden fields here. this should create trying accomplish much easier tackling autocompletion yourself.
jquery autocomplete hidden-field
No comments:
Post a Comment