Jump to content
UBot Underground

Ui Html Dropdown Values From Variable (Resolved)


Recommended Posts

I have created this little example code using Aymen's very nice ini plugin, and while the example works, I'm interested in learning how I can pass the values from #section names into a drop down in a UI HTML panel. 

 

I have considered building the html in a loop and pass that to a variable that is read by the HTML panel. Seems like a work around.

Next, how would I pass the selected value to a define. 

 

Is it a javascript job?

on load("Bot Loaded") {
    set(#ini_file,"{$special folder("Desktop")}/test.ini","Global")
}
ui button("Create ini file") {
    plugin command("IniFileReader.dll", "ini container", #ini_file) {
        plugin command("IniFileReader.dll", "ini write", "Profile 1", "profilename", "John Doe")
        plugin command("IniFileReader.dll", "ini write", "Profile 1", "Site", "http://www.google.com")
        plugin command("IniFileReader.dll", "ini write", "Profile 2", "profilename", "Jane Doe")
        plugin command("IniFileReader.dll", "ini write", "Profile 2", "Site", "http://www.bing.com")
        set(#section names,$replace($plugin function("IniFileReader.dll", "$ini get section names"),$new line,","),"Global")
    }
}
ui drop down("Section names",#section names,#selected_profile)
ui button("Load ini params") {
    plugin command("IniFileReader.dll", "ini container", #ini_file) {
        set(#section_site,$plugin function("IniFileReader.dll", "$ini read", #selected_profile, "Site"),"Global")
    }
}
ui stat monitor("Selected section:",#selected_profile)
ui stat monitor("Section site",#section_site)

Link to post
Share on other sites

Tried this example provided by jason: http://www.ubotstudio.com/forum/index.php?/topic/15102-solved-who-else-wants-the-optgroup-tag-to-be-fixed/?p=85657

set(#options,"one,2,3,four","Global")
ui html panel("<select variable=”#result” list=”#options” list-fillwith=“options”>
</select>",100)

Seems like a great solution, but can't get it to work even though I use the same example code - a bug perhaps?

post-12789-0-31792800-1422327590_thumb.png

Link to post
Share on other sites

For some reason the html wasn't "escaped" correctly - fixed it and modified my profile example using the ini plugin. Working example provided here

on load("Bot Loaded") {
    set(#ini_file,"{$special folder("Desktop")}/test.ini","Global")
    Create ini file()
}
ui html panel("<select variable=\"#selected_section\" list=\"#section_names\" list-fillwith=\"options\"></select>
<input type=\"button\" value=\"Load ini params\" class=\"btn\" onclick=\"ubot.runScript(\'Load ini params()\')\"></button>",100)
define Create ini file {
    alert("Creating ini file")
    plugin command("IniFileReader.dll", "ini container", #ini_file) {
        plugin command("IniFileReader.dll", "ini write", "Profile 1", "profilename", "John Doe")
        plugin command("IniFileReader.dll", "ini write", "Profile 1", "Site", "http://www.google.com")
        plugin command("IniFileReader.dll", "ini write", "Profile 2", "profilename", "Jane Doe")
        plugin command("IniFileReader.dll", "ini write", "Profile 2", "Site", "http://www.bing.com")
        set(#section_names,$replace($plugin function("IniFileReader.dll", "$ini get section names"),$new line,","),"Global")
    }
}
define Load ini params {
    plugin command("IniFileReader.dll", "ini container", #ini_file) {
        set(#section_site,$plugin function("IniFileReader.dll", "$ini read", #selected_section, "Site"),"Global")
    }
    alert("Selected section value: {#section_site}")
}
Link to post
Share on other sites
  • 3 weeks later...

Tried this example provided by jason: http://www.ubotstudio.com/forum/index.php?/topic/15102-solved-who-else-wants-the-optgroup-tag-to-be-fixed/?p=85657

set(#options,"one,2,3,four","Global")
ui html panel("<select variable=”#result” list=”#options” list-fillwith=“options”>
</select>",100)

Seems like a great solution, but can't get it to work even though I use the same example code - a bug perhaps?

How did you solve this problem?

I have the same with a strange variable

Link to post
Share on other sites

That code is missing the back slashes(needed if pasting code into code view). Paste the code below into code view:

set(#options, "one,2,3,four", "Global")
ui html panel("
 
<select variable=\"#result\" list=\"#options\" list-fillwith=\"options\">
</select>
</html>
", 100)
  • Like 1
Link to post
Share on other sites

Doesn't work anyway.

 

Mate if you can't get the code to work don't just come here and say it does'nt work. Share what your doing here like dyvel said.

 

The code DOES WORK. I'm not gonna paste code here if it does'nt work.

 

See for yourself: http://screencast.com/t/gNIOPGSEtI

Link to post
Share on other sites

Mate if you can't get the code to work don't just come here and say it does'nt work. Share what your doing here like dyvel said.

 

The code DOES WORK. I'm not gonna paste code here if it does'nt work.

 

See for yourself: http://screencast.com/t/gNIOPGSEtI

 

Yes it definitely worked!

Didnt know it's that simple.. Thanks!

 

Do you guys know how to trigger a define when you select a certain option on your dropdown menu?

I tried to put an onclick code on the option tag but it seems to be ignored.

Link to post
Share on other sites

I copied exactly the same code which you do.

Maybe it somehow depends of windows version?

UI drop down works with dynamic variables, but it's impossible to put them into program, when my all gui is in HTML, right?

Link to post
Share on other sites

I copied exactly the same code which you do.

Maybe it somehow depends of windows version?

UI drop down works with dynamic variables, but it's impossible to put them into program, when my all gui is in HTML, right?

 

My GUI is all HTML and I load the dynamic dropdown values as shown in my post #3

Have you checked you have values in your variable (check debugger).

 

Again - post some code - makes it easier to help :)

Link to post
Share on other sites

 

Do you guys know how to trigger a define when you select a certain option on your dropdown menu?

I tried to put an onclick code on the option tag but it seems to be ignored.

 

Just answering my own question here. Some members might be interested. Here's the link http://www.ubotstudio.com/forum/index.php?/topic/17629-free-code-selected-dropdown-menu-item-to-execute-a-define/

Link to post
Share on other sites
  • 1 month later...

Worked great.  Thanks!

 

UPDATE:  found that when I copied this simple code over to an existing UBOT that already had other UI OPEN FILE and UI STAT MONITOR commands, my drop-down menu is blank - no options (similar to ianshier's video).  I removed all other UI OPEN FILE and UI STAT MONITOR commands and the dropdown menu populated correctly.    It doesn't appear they can coexist.

Link to post
Share on other sites
  • 2 years later...

Hello,

Where do you get LIST and LIST-FILLWITH options? I have searched the docs online and did not get those.

 

Thanks.

 

Those are added to the HTML code when you make a UI using the ui html panel. I don't think there is any real documentation on it just something people have pointed out on the forum.

 

Not 100% sure what you're asking but if you're wondering if they are in Ubot they are not, you need to type them into the HTML directly.

Link to post
Share on other sites

Hello,

Thanks, yes I know, they are to be used in the HTML of the UI. I just can find any reference other than this forum. That's a very helpful option, or you have to iterate a list and format an innerhtml code, etc.

 

I have this option now:

<select id="mys" list="#listado" list-fillwith="options" class="form-control" multiple>
</select>

And I need to run this one every time the select changes:

<script type="text/javascript">
$("#mys").change(function() {
   ubot.runScript("updateBox(" + $('#mys').val() + ")");
});
</script>

The point is to store the multiple values selected in the select to another place, to use those options from there. As far as I know Ubot don't store multiple values from a select, right?

 

That runScript is not working for me right now, I have placed a Navigate in the define(to test it), and it never gets executed. The define store the "value" in the needed Ubot variable like this:

define updateBox(#valores) {
    set(#gruposdisplay,#valores,"Global")
}

Thanks for the help!

Link to post
Share on other sites
<select id="mys" list="#listado" list-fillwith="options" class="form-control" multiple onchange="doIt();">
</select>

<script type="text/javascript">
   function doIt(){
       ubot.runScript("updateValues(" + JSON.stringify($("#mys").val().join(", ")) + ")");
   }
</script>

I get it working using this. Well now I can use a SELECT multiple, and store those values elsewhere to use them in the ubot code.

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