I'm trying to coordinate the dynamic contents of a one select input based on the value of another. 'userselect' populates on page load and 'tblselect' populates fine the first time a userselect item is selected but it doesn't get refreshed with subsequent selects. Why not? Here's the code: <html><head> opt_display = function (row) { return OPTION({"value":row[0]}, row[1]); } function showSelectData(result) { var mydata = concat([[-1,'--']], result["data"]); html_select=SELECT({"onchange": "popTables(this.value);"}, map(opt_display, mydata)); swapDOM("userselect", html_select); } function showSelectData2(result) { var mydata2 = concat([[-1,'--']], result["data"]); html_select2=SELECT(null, map(opt_display, mydata2)); swapDOM("tblselect", html_select2); } function popTables(ownerName) { var url = "./" + ownerName // Note: user name is passed by the URL. It's a Quixote REST thing and it works var d2 = loadJSONDoc(url); d2.addCallback(showSelectData2); } var d1 = loadJSONDoc("./getUsers"); d1.addCallback(showSelectData); </script> </head> <body> <select id="userselect"><option value="-1">--</option></select> <select id="tblselect"><option value="-1">--</option></select> </body></html>
I'm a Javascript newbie so any refactoring simplification is welcome.