drewness 26 Posted January 26, 2017 Report Share Posted January 26, 2017 (edited) Hi There, I'm trying to fire a UBot define after a user selects an item from a dynamically loaded dropdown in the HTML UI panel. I've tried setting the onchange event to call a Ubot define like so: <select variable="#itemToView" list="#itemDropdownList" list-fillwith="options" onchange="ubot.runScript('testLoader()')"></select> I've also tried setting it to call a javascript function onchange, which in turn calls the UBot define, but have the same issue with it firing as soon as the bot loads and populates the dropdown. I've tried targeting the elements ID in a <script> at the footer like so: document.getElementById('itemDropdown').onchange = function() { ubot.runScript('testLoader()');} with the same issue. onclick and onblur also have the same issues. Any idea on how I can prevent it from firing until the user actually chooses something from the dropdown? Thanks in advance! Edited January 26, 2017 by drewness Quote Link to post Share on other sites
HelloInsomnia 1103 Posted January 26, 2017 Report Share Posted January 26, 2017 Here's what you are doing basically: ui html panel("<select variable=\"#itemToView\" list=\"#itemDropdownList\" list-fillwith=\"options\" onchange=\"ubot.runScript(\'testLoader()\')\"></select>",100) set(#itemDropdownList,"one,two","Global") define testLoader { alert("selection changed") } Here is probably what you want: ui html panel("<select variable=\"#itemToView\" list=\"#itemDropdownList\" list-fillwith=\"options\" onchange=\"ubot.runScript(\'testLoader()\')\"></select>",100) set(#itemDropdownList,"(select),one,two","Global") define testLoader { if($comparison(#itemToView,"=","(select)")) { then { comment("Do nothing") } else { alert("selection changed") } } } 1 Quote Link to post Share on other sites
drewness 26 Posted January 26, 2017 Author Report Share Posted January 26, 2017 You're a genius, thank you so much! Works perfectly, exactly what I needed. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.