Jump to content
UBot Underground

Recommended Posts

I'm stuck, I need to select 2 items on a dropdown menu (listbox) but cannot find native ability to do it within ubot. I'd imagine that I will need to accomplish this using Javascript. Does anyone have experience with this? I have pasted the code for the listbox/dropdown menu below:

<table cellspacing='0' cellpadding='3' border='0'>      <tr><td valign='top'><b>Items</b> </td><td  class="internalColumn"><label for='ITEMS'><select style=' width: 100%;' title="Select ITEMS to search.  Hold down CTRL to select multiple counties." id='ITEMS' name='ITEMS' size='7' multiple='multiple'><option title="All Counties.  Use the CTRL key to select multiple individual counties." value='' selected='selected' >-- ALL --</option><option  value="58" title="Red">Red</option><option  value="59" title="White">White</option><option  value="60" title="Blue, WA">Blue</option><option  value="61" title="Yellow">Yellow</option><option  value="51" title="Green">Green</option></select></label></td></tr> <tr><td colspan='2'><i>Hold down CTRL to select multiple items</i></td></tr>
Link to post
Share on other sites

load html("<table cellspacing=\'0\' cellpadding=\'3\' border=\'0\'>      <tr><td valign=\'top\'><b>Items</b> </td><td  class=\"internalColumn\"><label for=\'ITEMS\'><select style=\' width: 100%;\' title=\"Select ITEMS to search.  Hold down CTRL to select multiple counties.\" id=\'ITEMS\' name=\'ITEMS\' size=\'7\' multiple=\'multiple\'><option title=\"All Counties.  Use the CTRL key to select multiple individual counties.\" value=\'\' selected=\'selected\' >-- ALL --</option><option  value=\"58\" title=\"Red\">Red</option><option  value=\"59\" title=\"White\">White</option><option  value=\"60\" title=\"Blue, WA\">Blue</option><option  value=\"61\" title=\"Yellow\">Yellow</option><option  value=\"51\" title=\"Green\">Green</option></select></label></td></tr> <tr><td colspan=\'2\'><i>Hold down CTRL to select multiple items</i></td></tr>")
comment("Deselects all")
run javascript("select.selectedIndex = -1;")
comment("Will select more than 1")
run javascript("var optionsToSelect = [\'White\', \'Green\'];
var select = document.getElementById( \'ITEMS\' );

for ( var i = 0, l = select.options.length, o; i < l; i++ )
\{
  o = select.options;
  if ( optionsToSelect.indexOf( o.text ) != -1 )
  \{
    o.selected = true;
  \}
\}")

Link to post
Share on other sites

 

 

Thanks LoWrIdErTJ, I added the code to a run javascript node and ran the node, but no joy (I probably missed something). I made some revisions to the code you gave which worked. I have posted the code below for future reference for those that might need it:

 

var optionsToSelect = ['White', 'Green'];
var select = document.getElementById( 'ITEMS' );


for ( var i = 0, l = select.options.length, o; i < l; i++ )
{
  o = select.options[i];
  if ( optionsToSelect.indexOf( o.text ) != -1 )
  {
    o.selected = true;
  }
}
  • 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...