VBE IE Dropdown Selection Call - html

I'm facing an issue with one part of my code. Namely, situation where I am unable to select options from the "widget dropdown menu". I have tried calling the ID and classname with no success (no errors but also nothing is happening).
My VBA:
IE.document.getelementbyid("orgSelection").Focus
IE.document.getelementbyid("orgSelection").selectedindex = 2
IE.document.getelementbyid("orgSelection").FireEvent "onchange"
I have tried this (but also no luck):
IE.document.getelementbyid("orgSelection").Value = "Cats"
I have tried advice from here as well
Source code from IE:
<div class="ui-widget uiWidgetDiv">
<input class="onSubmitValue" id="onSubmitValue" type="hidden" value="selectedOrg">
<input class="statusValue_orgName" id="statusValue_orgName" type="hidden" value="">
<input name="selectedOrg" class="statusValue_orgID" id="statusValue_orgID" type="hidden" value="">
<select class="regular" id="orgSelection" style="display: none;">
<option value="">--Select--</option>
<option value="Cats">
Cats
</option>
<option value="dogs">
dogs
</option>
<option value="--ALL--.issuer">
--ALL--
</option>
<input class="regular ui-autocomplete-input ui-widget ui-widget-content ui-corner-left" style="width: 195px;" placeholder="--Select--" autocomplete="off"><button tabindex="-1" title="Enter minimum 3 characters or more to narrow search results.
Only first 500 organizations displayed." class="ui-button ui-widget ui-button-icon-only ui-corner-right ui-button-icon" type="button"><span class="ui-button-icon ui-icon ui-icon-triangle-1-s"></span><span class="ui-button-icon-space"> </span> </button><input class="onlyAll" id="onlyAll" type="hidden" value="1">
Can you please advise?
PS. The "Cats" and "dogs" are held in a dropdown menu which is referred to (in web source code) as "ui widget" - not sure if that supports the approach?

I have solved it:
'calling dropdown to open
IE.Document.GetElementsByClassName("ui-button ui-widget ui-button-icon-only ui-corner-right ui-button-icon")(0).Click
'selecting first option from the dropdown
IE.Document.GetElementsByClassName("ui-corner-all")(1).Click
There was no need to "execute" or send ~Enter to progress with the selection as the widget automatically uploaded data.

Related

How to modify this HTML form to include a constant?

Here's an example of a search in our SirsiDynix Enterprise catalog using the CloudSourceOA option te=750777545
https://nyit.ent.sirsi.net/client/en_US/default/search/results?qu=html&te=750777545&rt=false%7C%7C%7C%3ECSOA%3Ctitle%7C%7C%7CTitle
I want to pass the variables from a form in libguides to the enterprise. I have a working example for searching "Everything" and a broken example for the CloudSourceOA
My Form sends the search types like title and the term that the user enters in the input field to the qu=, however, I don't know how to append the te=750777545. This value will always be set as I want the widget to always search cloudsource rather than everything.
Here's a link to my libguide for troubleshooting. I was unable to add the code successfully here.
https://libguides.nyit.edu/c.php?g=1216772&p=8899584&preview=77a637b8476d8bbe2575a12fd18e3b61
It's unclear what te or the 750777545 value is, but if you need to hardcode that to your form you can do so with a hidden input set to that value. Fair warning, without knowing what this form field is, this may not be the best approach so you'll want to consult any documentation if this is specific to an internal NYIT application.
<form action="https://nyit.ent.sirsi.net/client/en_US/default/search/results?" id="searchForm" method="&te=""get"" name="searchForm">
<h5>Search the NYIT Catalogue</h5>
<div class="searchline">
<input name="ln" type="hidden" value="en_US"><br>
<select class="dropDown" id="restrictionDropDown" name="rt">
<option value="">
All Fields
</option>
<option value="false|||TITLE|||Title">
Title
</option>
<option value="false|||AUTHOR|||AUTHOR">
Author
</option>
<option value="false|||SUBJECT|||SUBJECT">
Subject
</option>
<option value="false|||ISBN|||ISBN">
ISBN
</option>
<option value="false|||ISSN|||ISSN">
ISSN
</option>
<option value="false|||DOI|||DOI">
DOI
</option>
<option value="false|||JOURNAL|||Journal Title">
Journal Title
</option>
</select>
<input type="hidden" id="te" name="te" value="750777545">
<p><input accesskey="s" id="qu" maxlength="256" name="qu" style="width:250px;" title="Search For:" type="text" value=""><input class="button" id="searchButton" title="Search" type="submit" value="Search"></p>
</div>
</form>

Revert back to full screen after inputting selection on Mobile

I have an option to select a wireless carrier from a list - the problem is that Iphone "zooms in" when creating the selectable dropdown list similar to this:
http://winmobiletech.com/012009Browsers/IMG_0017.PNG
My code is as follows:
<div id="popup-action-sms" style="display:none" >
<div id="sms" >
<input type="number" id="sms-tel" placeholder="Enter phone number" />
<select id="sms-carriers">
<option value="" >Select Wireless Carrier</option>
<option value="Alltel">Alltel</option>
<option value="AT&T">AT&T</option>
<option value="Sprint">Sprint</option>
<option value="T-Mobile">T-Mobile</option>
<option value="Verizon Wireless">Verizon Wireless</option>
</select>
</div>
</div>
My question How can I dynamically "zoom out" back to full screen once a user has selected their carrier?
$( "#sms-carriers" ).change(function() {
$(this).blur();
});
You can also try $(this).focusout();
Worth giving a shot :)

Html table scraping using Rvest with dropdown boxes

I would like to scrape a html table using rvest which has three dropdown boxes. When i select the option from the three, it will give a html table with no submit button. The website looks like this
These are three options (cascade line 1/cascade line 2 ), (date) and (shift A /shift B /shift C). This gives me error when i try to select cascade table 1 alone.
station_id <- url %>% html_nodes("#select.cascade_selection,table") %>% html_attr("1") %>%
html_table()
Error in UseMethod("html_table") : no applicable method for
'html_table' applied to an object of class "character"
How i do give all the three options and get the table using rvest ? Below added the inspect element of each options
<select class="form-control select2-hidden-accessible" style="width: 100%;" tabindex="-1" aria-hidden="true" id="cascade_selection" onchange="shiftSelection(0,2)">
<option value="1" selected="selected">Cascade Line 1</option>
<option value="2">Cascade Line 2</option>
</select>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"/>
</div>
<input type="text" class="form-control pull-left" id="dateRangeSelected" style="background:white;" data-disable-touch-keyboard=""/>
</div>
<!--/.input group-->
<select class="form-control select2-hidden-accessible" style="width: 100%;" tabindex="-1" aria-hidden="true" id="shift_selection" onchange="shiftSelection(0,2)">
<option value="A" selected="selected">Shift A</option>
<option value="B">Shift B</option>
<option value="C">Shift C</option>
</select>

Multiple Select in JQuery Mobile becomes empty when I change it to multiple

I do have a html input field select that is populated dynamically with values from MySQL database using jquery mobile. It is working perfectly but now I needed to change it to multiple select of options.
Please, see how my input was before this change:
<div id="landmark-1" data-landmark-id="1">
<form id = "cname" onsubmit="return submitForm();">
<label for "id">Employee's Name:</label><br/>
<select name="id" id="id">
<option value=""></option>
</select><br/>
<input type="submit" value="Clock-In" id="enviar_in" data-inline="true">
</form>
</div>
Now, see how it looks like after I changed it to accept multiple select:
<div id="landmark-1" data-landmark-id="1">
<form id = "cname" onsubmit="return submitForm();">
<label for "id">Employee's Name:</label><br/>
<select name="id" id="id" multiple="multiple" data-native-menu="false">
<option value=""></option>
</select><br/>
<input type="submit" value="Clock-In" id="enviar_in" data-inline="true">
</form>
</div>
It pop up the box for multi-select the options with the "x" to close the box and everything but does not show the populated data from MySQL.
Is there any thing that I am missing?
Thank you in advance.
Have you tried this. After the select is populated dynamically update the select using refresh().
//refresh value
$('#id').selectmenu('refresh');
//refresh and force rebuild
$('#id').selectmenu('refresh', true);
Refresh the select menu after populating .
$('#id').selectmenu('refresh');

submitting a text search using jsoup

I have a piece of html code which represents a part of a website that is supposed to be the search widget for a directory of a faculty in a university
<div id="right_column" class="content_main">
<div class="searchbox">
<form method="POST" action="/faculty/directory_search/" id="searchform">
<h4>Search the Directory</h4>
<input type="text" name="searchterms" value="" />
<select name="category" class="dropdown"> <option value="all" selected="selected">All Categories</option> <option value="Faculty">Faculty</option> <option value="Staff">Staff</option> <option value="Visitors">Visitors</option> <option value="Full time">Full time</option> <option value="Visiting">Visiting</option> <option value="Special Appointment">Special Appointment</option> <option value="Biological Sciences">Biological Sciences</option> </select>
<input type="hidden" name="sort" value="asc" />
<input type="submit" class="submit" value="Search directory" />
<a class="button" href="/faculty/index/desc" id="sortbutton">Sort Alphabetically</a>
</form>
<script type="text/javascript">
$('#searchform').ready(function(){
$('#sortbutton').click(function(){
$('input[name="sort"]').val('desc');
$('#searchform').submit();
return false;
});
});
</script>
</div>
I am trying to input the name "john" and submit the search using jsoup using the following java code (intended for android but it's overall the same java code as for a regular java app)
Document doc = Jsoup.connect("http://www.qatar.cmu.edu/directory/").data("searchterms", "john").post();
However, I keep getting the same page as just "http://www.qatar.cmu.edu/directory/" with no search submitted. I noticed that in the html code there is the submit input type. I'm wondering if I had to submit the search. If so, how can it be done?
I believe you are performing a POST request to the page containing the form, not the forms endpoint. This should work:
Document doc = Jsoup.connect("http://www.qatar.cmu.edu/faculty/directory_search/").data("searchterms", "john").data("sort", "asc").data("category", "all").post();
It makes the POST request directly to the forms endpoint.