Jump to content
UBot Underground

Preventing Javascript From Running As Bot Loads


Recommended Posts

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 by drewness
Link to post
Share on other sites

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")
        }
    }
}
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...