allcapone1912 7 Posted February 2, 2017 Report Share Posted February 2, 2017 How to pass a text parameter to HTML panel? example: ui html panel("<button onclick=\"ubot.runScript(\'SetStatus()\')\">GOOD</button> <button onclick=\"ubot.runScript(\'SetStatus()\')\">BAD</button> ",100) define SetStatus(#Status) { alert(#Status) } On click GOOD should alert "Good" I've tried: ubot.runScript(\'SetStatus(Good)\') ubot.runScript(\'SetStatus('Good')\') ubot.runScript(\'SetStatus(\"Good\")\') Any idea how to do that? I want to use only 1 define ubot.runScript(\'SetStatus(#different var for each button)\') Quote Link to post Share on other sites
Macster (UBotter Labs) 112 Posted February 2, 2017 Report Share Posted February 2, 2017 To output a status to HTML: <span variable="#status" fillwith="innerhtml"></span>To use button for action on a define i.e click_me() : <input type="button" title="Button" value="Click Me" onclick="ubot.runScript('click_me()')">To better play with HTML i would recommend you looke a Darryl's GUI Hero or at LazyBotter's SSUB 1 Quote Link to post Share on other sites
darryl561 177 Posted February 3, 2017 Report Share Posted February 3, 2017 If I'm right about what you are trying to do the code below should do it. Where you have ubot.runScript(\'SetStatus(Good)\') you need to replace Good with a numerical value. ui html panel("<button onclick=\"ubot.runScript(\'SetStatus(0)\')\">GOOD</button> <button onclick=\"ubot.runScript(\'SetStatus(1)\')\">BAD</button> ",100) define SetStatus(#Status) { if($comparison(#Status,"= Equals",0)) { then { set(#Status2,"Good","Global") } else { set(#Status2,"Bad","Global") } } alert(#Status2) } Quote Link to post Share on other sites
HelloInsomnia 1103 Posted February 3, 2017 Report Share Posted February 3, 2017 You can pass a string by encoding the quotes: ui html panel("<input type=\"button\" value=\"Alert Button\" onclick=\"ubot.runScript(\'AlertMe("my string")\')\">",100) define AlertMe(#string) { alert(#string) } 2 Quote Link to post Share on other sites
deliter 203 Posted February 16, 2017 Report Share Posted February 16, 2017 You can pass a string by encoding the quotes: ui html panel("<input type=\"button\" value=\"Alert Button\" onclick=\"ubot.runScript(\'AlertMe("my string")\')\">",100) define AlertMe(#string) { alert(#string) } Why do they bother making features, if their not going to document it, thanks for posting this Quote Link to post Share on other sites
deliter 203 Posted February 16, 2017 Report Share Posted February 16, 2017 just on this to pass ubot commands arguments from ubot.runScript on Javascript, just use the blackslash before quotations, thanks HInsomnia for this, never thought ubot could pass arguments from Javascript, really handy 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.