sifuhall 0 Posted July 29, 2014 Report Share Posted July 29, 2014 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\")')\"> Quote Link to post Share on other sites
kev123 132 Posted July 29, 2014 Report Share Posted July 29, 2014 You can pass numbers Quote Link to post Share on other sites
sifuhall 0 Posted July 29, 2014 Author Report Share Posted July 29, 2014 Thanks. I had to get a bit creative but that works! Quote Link to post Share on other sites
UBotDev 276 Posted July 30, 2014 Report Share Posted July 30, 2014 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 numbersYou 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 ("). 3 Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted July 30, 2014 Report Share Posted July 30, 2014 Thats a great trick ubotdev! Thanks for sharing it.This is gonna be useful. Quote Link to post Share on other sites
sifuhall 0 Posted July 30, 2014 Author Report Share Posted July 30, 2014 Thanks for sharing that! In my case I loaded the vars into a list and passed the index as the variable Quote Link to post Share on other sites
UBotDev 276 Posted July 31, 2014 Report Share Posted July 31, 2014 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 variableGreat workaround. Quote Link to post Share on other sites
kev123 132 Posted July 31, 2014 Report Share Posted July 31, 2014 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 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.