Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #11702 > unrolled thread

fill in ie form with java

Started bysmbs <stevenbe@gmail.com>
First post2017-07-09 01:31 -0700
Last post2017-07-09 13:46 -0400
Articles 7 — 5 participants

Back to article view | Back to microsoft.public.scripting.vbscript


Contents

  fill in ie form with java smbs <stevenbe@gmail.com> - 2017-07-09 01:31 -0700
    Re: fill in ie form with java "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2017-07-09 04:57 -0400
    Re: fill in ie form with java Ulrich Möller <knobbi38@arcor.de> - 2017-07-09 15:52 +0200
      Re: fill in ie form with java smbs <stevenbe@gmail.com> - 2017-07-09 08:02 -0700
        Re: fill in ie form with java Ulrich Möller <knobbi38@arcor.de> - 2017-07-09 18:49 +0200
    Re: fill in ie form with java JJ <jj4public@vfemail.net> - 2017-07-09 23:34 +0700
    Re: fill in ie form with java "Mayayana" <mayayana@invalid.nospam> - 2017-07-09 13:46 -0400

#11702 — fill in ie form with java

Fromsmbs <stevenbe@gmail.com>
Date2017-07-09 01:31 -0700
Subjectfill in ie form with java
Message-ID<f4606ee4-abaa-49b4-9c5e-922fe8240ced@googlegroups.com>
I am trying to select items from a dropdown menu on a javascript webpage. I want to fill in the menu value via a userform using VB.  Relevent Web code source is below

***************************************************************************************
<div class="sa-form-control sa-form-field" style="padding-bottom: 20px;">
<select name="country" class="ui-textfield ui-textfield-system sa-country sa-error-field"><option selected="selected" value="">--Please Select--</option>
<option value="RU">Russian Federation</option>
<option value="US">United States</option>
<option value="ES">Spain</option>
<option value="FR">France</option>
option value="OTHER">Other Country</option>
<option value="">-------- Country &amp; Territories (A-Z) --------</option></select>
<div class="sa-success-icon" style="display: none;"></div><p class="sa-error-tips" style="display: block;">Please select a Country/Region</p></div>
**************************************************************************************************
I have tried the following
oIE.document.getElementsByClassName("ui-textfield ")(0).Value = "RU"
not working
oIE.document.getElementsByName("country")(0).Value = "RU"
Also not working
Any help would be great
Thanx

[toc] | [next] | [standalone]


#11703

From"Dave \"Crash\" Dummy" <invalid@invalid.invalid>
Date2017-07-09 04:57 -0400
Message-ID<ojsqua$aoj$1@dont-email.me>
In reply to#11702
smbs wrote:
> I am trying to select items from a dropdown menu on a javascript
> webpage. I want to fill in the menu value via a userform using VB.
> Relevent Web code source is below
> 
> ***************************************************************************************
>  <div class="sa-form-control sa-form-field" style="padding-bottom:
> 20px;"> <select name="country" class="ui-textfield
> ui-textfield-system sa-country sa-error-field"><option
> selected="selected" value="">--Please Select--</option> <option
> value="RU">Russian Federation</option> <option value="US">United
> States</option> <option value="ES">Spain</option> <option
> value="FR">France</option> option value="OTHER">Other
> Country</option> <option value="">-------- Country &amp; Territories
> (A-Z) --------</option></select> <div class="sa-success-icon"
> style="display: none;"></div><p class="sa-error-tips" style="display:
> block;">Please select a Country/Region</p></div> 
> **************************************************************************************************
>  I have tried the following 
> oIE.document.getElementsByClassName("ui-textfield ")(0).Value = "RU" 
> not working oIE.document.getElementsByName("country")(0).Value = "RU"
>  Also not working Any help would be great Thanx

Try it without the "oIE" object:
document.getElementsByName("country")(0).Value = "RU"
-- 
Crash

"Politics have no relation to morals."
~ Niccolo Machiavelli ~

[toc] | [prev] | [next] | [standalone]


#11704

FromUlrich Möller <knobbi38@arcor.de>
Date2017-07-09 15:52 +0200
Message-ID<ojtc6j$sto$1@dont-email.me>
In reply to#11702
Am 09.07.2017 um 10:31 schrieb smbs:
> I am trying to select items from a dropdown menu on a javascript webpage. I want to fill in the menu value via a userform using VB.  Relevent Web code source is below
>
> ***************************************************************************************
> <div class="sa-form-control sa-form-field" style="padding-bottom: 20px;">
> <select name="country" class="ui-textfield ui-textfield-system sa-country sa-error-field"><option selected="selected" value="">--Please Select--</option>
> <option value="RU">Russian Federation</option>
> <option value="US">United States</option>
> <option value="ES">Spain</option>
> <option value="FR">France</option>
> option value="OTHER">Other Country</option>
> <option value="">-------- Country &amp; Territories (A-Z) --------</option></select>
> <div class="sa-success-icon" style="display: none;"></div><p class="sa-error-tips" style="display: block;">Please select a Country/Region</p></div>
> **************************************************************************************************
> I have tried the following
> oIE.document.getElementsByClassName("ui-textfield ")(0).Value = "RU"
> not working
> oIE.document.getElementsByName("country")(0).Value = "RU"
> Also not working
This code should work:
   oIE.Document.getElementsByName("country")(0).Value = "RU"
or
   oIE.Document.All("country").Value = "RU"

but maybe you have any security issues. In doubt, post a snipped on how 
you create and access the IE object.

Ulrich

[toc] | [prev] | [next] | [standalone]


#11705

Fromsmbs <stevenbe@gmail.com>
Date2017-07-09 08:02 -0700
Message-ID<46cdd6c3-0238-4667-95f5-2d3504fc6af6@googlegroups.com>
In reply to#11704
On Sunday, July 9, 2017 at 4:51:58 PM UTC+3, Ulrich Möller wrote:
> Am 09.07.2017 um 10:31 schrieb smbs:
> > I am trying to select items from a dropdown menu on a javascript webpage. I want to fill in the menu value via a userform using VB.  Relevent Web code source is below
> >
> > ***************************************************************************************
> > <div class="sa-form-control sa-form-field" style="padding-bottom: 20px;">
> > <select name="country" class="ui-textfield ui-textfield-system sa-country sa-error-field"><option selected="selected" value="">--Please Select--</option>
> > <option value="RU">Russian Federation</option>
> > <option value="US">United States</option>
> > <option value="ES">Spain</option>
> > <option value="FR">France</option>
> > option value="OTHER">Other Country</option>
> > <option value="">-------- Country &amp; Territories (A-Z) --------</option></select>
> > <div class="sa-success-icon" style="display: none;"></div><p class="sa-error-tips" style="display: block;">Please select a Country/Region</p></div>
> > **************************************************************************************************
> > I have tried the following
> > oIE.document.getElementsByClassName("ui-textfield ")(0).Value = "RU"
> > not working
> > oIE.document.getElementsByName("country")(0).Value = "RU"
> > Also not working
> This code should work:
>    oIE.Document.getElementsByName("country")(0).Value = "RU"
> or
>    oIE.Document.All("country").Value = "RU"
> 
> but maybe you have any security issues. In doubt, post a snipped on how 
> you create and access the IE object.
> 
> Ulrich

Thanx for reply however what you suggested does not work- no security issues as other text blocks are filled in without problems

[toc] | [prev] | [next] | [standalone]


#11707

FromUlrich Möller <knobbi38@arcor.de>
Date2017-07-09 18:49 +0200
Message-ID<ojtmie$spc$1@dont-email.me>
In reply to#11705
Am 09.07.2017 um 17:02 schrieb smbs:
> On Sunday, July 9, 2017 at 4:51:58 PM UTC+3, Ulrich Möller wrote:
>> Am 09.07.2017 um 10:31 schrieb smbs:
>>> I am trying to select items from a dropdown menu on a javascript webpage. I want to fill in the menu value via a userform using VB.  Relevent Web code source is below
>>>
>>> ***************************************************************************************
>>> <div class="sa-form-control sa-form-field" style="padding-bottom: 20px;">
>>> <select name="country" class="ui-textfield ui-textfield-system sa-country sa-error-field"><option selected="selected" value="">--Please Select--</option>
>>> <option value="RU">Russian Federation</option>
>>> <option value="US">United States</option>
>>> <option value="ES">Spain</option>
>>> <option value="FR">France</option>
>>> option value="OTHER">Other Country</option>
>>> <option value="">-------- Country &amp; Territories (A-Z) --------</option></select>
>>> <div class="sa-success-icon" style="display: none;"></div><p class="sa-error-tips" style="display: block;">Please select a Country/Region</p></div>
>>> **************************************************************************************************
>>> I have tried the following
>>> oIE.document.getElementsByClassName("ui-textfield ")(0).Value = "RU"
>>> not working
>>> oIE.document.getElementsByName("country")(0).Value = "RU"
>>> Also not working
>> This code should work:
>>     oIE.Document.getElementsByName("country")(0).Value = "RU"
>> or
>>     oIE.Document.All("country").Value = "RU"
>>
>> but maybe you have any security issues. In doubt, post a snipped on how
>> you create and access the IE object.
>>
>> Ulrich
> Thanx for reply however what you suggested does not work- no security issues as other text blocks are filled in without problems
I have tested both variations with a little test program and it works as 
expected. Check for any typo in your element names. You also have the 
option to set a break point in your vb code and try to change the value 
in the direct window.

Ulrich

[toc] | [prev] | [next] | [standalone]


#11706

FromJJ <jj4public@vfemail.net>
Date2017-07-09 23:34 +0700
Message-ID<17n802pm4b0uy.1tkuz7h616iwf$.dlg@40tude.net>
In reply to#11702
On Sun, 9 Jul 2017 01:31:29 -0700 (PDT), smbs wrote:
> I am trying to select items from a dropdown menu on a javascript webpage. I want to fill in the menu value via a userform using VB.  Relevent Web code source is below
> 
> ***************************************************************************************
> <div class="sa-form-control sa-form-field" style="padding-bottom: 20px;">
> <select name="country" class="ui-textfield ui-textfield-system sa-country sa-error-field"><option selected="selected" value="">--Please Select--</option>
> <option value="RU">Russian Federation</option>
> <option value="US">United States</option>
> <option value="ES">Spain</option>
> <option value="FR">France</option>
> option value="OTHER">Other Country</option>
> <option value="">-------- Country &amp; Territories (A-Z) --------</option></select>
> <div class="sa-success-icon" style="display: none;"></div><p class="sa-error-tips" style="display: block;">Please select a Country/Region</p></div>
> **************************************************************************************************
> I have tried the following
> oIE.document.getElementsByClassName("ui-textfield ")(0).Value = "RU"
> not working
> oIE.document.getElementsByName("country")(0).Value = "RU"
> Also not working
> Any help would be great
> Thanx

Unless you've already made the code to be executed suring the "load" event

Try moving the SCRIPT element after the SELECT element.

[toc] | [prev] | [next] | [standalone]


#11708

From"Mayayana" <mayayana@invalid.nospam>
Date2017-07-09 13:46 -0400
Message-ID<ojtpug$87s$1@dont-email.me>
In reply to#11702
"smbs" <stevenbe@gmail.com> wrote

|I am trying to select items from a dropdown menu on a javascript webpage. I 
want to fill in the menu value via a userform using VB.  Relevent Web code 
source is below
|

Are you in the page? If so then either of the
following options will work. You don't need the
inefficiency of "all".

<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
Sub But1_onclick()
 'List1.selectedIndex = 3
List1.value = "FR"
End Sub
</SCRIPT>
</HEAD>
<BODY>

<SELECT ID="List1">
<option value="RU">Russian Federation
<option value="US">United States
<option value="ES">Spain
<option value="FR">France
<option value="OTHER">Other Country
</SELECT>


<INPUT ID="But1" TYPE="button"></input>
</BODY></HTML>

  The NAME attribute also seems to work in
place of ID. This is all only in IE, of course. And
with any IE webpage code these days you
need to consider quirks mode vs non-quirks.
Also note that if it's not an HTA then IE11 won't
recognize VBS unless you set compat mode for
the domain. (I'm not sure how that works locally.)

  If you're not calling from within the document
context then where are you? In that case you
need to first get the document reference. If it's
not your IE instance then you may not be able
to get at the document object, which would then
require an API call that's not possible from script.
You could try this if necessary:

http://www.jsware.net/jsware/compfiles.php5#jsshl

  It's a component for shell functionality. In addition
to things like enumerating windows and getting their
handles, it can return an IE document object from IE,
an HTA, or any other window that has a true IE
browser window in it. The only trick is that IE with tabs
makes finding the desired window more tricky.

  Another thing that might be helpful:

http://www.jsware.net/jsware/hxs2chm.php5

  That requires a bit of explanation. The IE document
object model is vast. You should really have the help
docs for it. The problem is that the Inet CHM is about
35 MB and CHMs are no longer made available. All
docs are now in the platform SDK, which is a gigantic
package. The help files come as HKS files, for which
there's no standalone reader. It's a pain to just get
basic help files for WSH, IE, etc.

  The page above links to an HTA utility you can
use. Download an SDK. (Win7 would probably be
a good choice.) Get out the HXS files, and the utility
will convert them. You'll end up with CHM files covering
all categories of Windows development. The details
to do it are at the link. Once you have an Inet CHM
you can easily look up all details of the IE DOM. 

[toc] | [prev] | [standalone]


Back to top | Article view | microsoft.public.scripting.vbscript


csiph-web