javascript - Get selectbox expand/user focus event -


i have select box element in form. when clicked, want generate options display , insert html code.

i have tried placing alerts on onclick, onfocus, onshow events, nothin happens :/

the html:

<select name="select-building" id="select-building" data-native-menu="false" onfocus="populatebuildingoptions();"> </select> 

the javascript:

function populatebuildingoptions(){ b = "{{\"buildingcode\":\"1\",\"buildingname\":\asca"\"},{\"buildingcode\":\"2\",\"buildingname\":\"vsdvs\"}}"; buildingoptions = jquery.parsejson(b); $("#select-building").empty(); for(var i=0;i<buildingoptions.length;i++){ $("#select-building").append("<option value=\""+buildingoptions.get(i).buildingcode+"\">"+buildingoptions.buildingname+"/option>" ); } } 

i got work on jsfiddle: http://jsfiddle.net/utjzv/4/ in comments


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -