Jump to content
UBot Underground

Passing Parameters In The UI HTML


Recommended Posts

Trying to pass parameters in the UI HTML.

 

Works great without parameters.

 

For example, this works:

<input type=\"button\" value=\"button\" onclick=\"ubot.runScript('loadMain()')\">

But this does not

<input type=\"button\" value=\"button\" onclick=\"ubot.runScript('loadMain(\"http://www.google.com\")')\">
Link to post
Share on other sites

Thanks.

 

I had to get a bit creative but that works!

And why wouldn't you share your solution with others to help them? 

 

 

You can pass numbers

You can actually pass strings as well, it's just a bit more tricky...

 

Here is a working solution:

ui html panel("<input type=\"button\" value=\"button\" onclick=\"ubot.runScript(\'loadMain("Test string from html!")\')\">", "")
define loadMain(#test) {
    alert(#test)
}

Notice that instead of escaping Ubot double quotes around input parameters with \ (as in Sifuhall's example), you actually need to HTML encode the double quotes (").

  • Like 3
Link to post
Share on other sites

Thats a great trick ubotdev! Thanks for sharing it.

This is gonna be useful.

Nice to hear.

 

Thanks for sharing that!

 

In my case I loaded the vars into a list and passed the index as the variable

Great workaround.

Link to post
Share on other sites

 

And why wouldn't you share your solution with others to help them? 

 

 

You can actually pass strings as well, it's just a bit more tricky...

 

Here is a working solution:

ui html panel("<input type=\"button\" value=\"button\" onclick=\"ubot.runScript(\'loadMain("Test string from html!")\')\">", "")
define loadMain(#test) {
    alert(#test)
}

Notice that instead of escaping Ubot double quotes around input parameters with \ (as in Sifuhall's example), you actually need to HTML encode the double quotes (").

 

great I can get rid of my complex indexing code now(used to pass numbers)

thanks

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...