☠ℬαłłℓℯωℯ♭☠ 10 Posted April 17, 2015 Report Share Posted April 17, 2015 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> Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted April 17, 2015 Report Share Posted April 17, 2015 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; \}\}") Quote Link to post Share on other sites
☠ℬαłłℓℯωℯ♭☠ 10 Posted April 17, 2015 Author Report Share Posted April 17, 2015 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; } } 1 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.