TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Software World > Programming

Powershell and IE

Programming

 
Reply
Thread Tools Display Modes
Unread 18-10-2016, 08:35 PM   #1
Newbie
Thread Starter
 
Join Date: Oct 2016
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0 unixfan is an unknown quantity at this point

AMD Nvidia

Windows 98 / Windows ME Windows NT / Windows 2000 Windows XP Windows Server Windows 7 Windows 10 Linux


Question Powershell and IE

Dear All,
I am using IE as GUI for powershell. This is quite fine, since we are using therefore only standard office tools. My powershell script opens a HTML page and waits in a loop for events. I am using two hidden fields, one provides an end criterium for the loop:
Code:
while ( $ExitLoop -eq $false ) {
      $ExitLoop = $objIE.document.getElementById("ExitLoop").value
      $Action = $objIE.document.getElementById("Action").value

The$Action now gets executed. In the form however I have also a list which I would like to populate from the powershell script. I initialise it :
Code:
 <select name="Emails" width="60" STYLE="width: 60px" size="10" />
and I try to access it:
Code:
     $EmailsList=$objIE.document.getElementById("Action").value
but this does not work.Any idea, why ?And more important still, any idea how I can access this select list ?Thank you very much for any hint
Yours
Eryk

Sponsored Links

Last edited by Strider; 19-10-2016 at 11:55 AM.. Reason: Code formatting added
unixfan is offline   Reply With Quote
Unread 19-10-2016, 11:57 AM   #2
Webmaster
 
Strider's Avatar
 
Join Date: Nov 2005
Location: Interwebs
Posts: 5,046
Thanks: 637
Thanked 730 Times in 613 Posts
Mood: Busy
Blog Entries: 6
Rep Power: 9045 Strider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly Eminent

Intel Nvidia

Windows Server Windows 7 Windows 10 Linux


Re: Powershell and IE

I'm not a PS expert but I'd imagine it'll be something like:

Code:
     $EmailsList=$objIE.document.getElementById("Emails")
     EmailsList.Value = $Action
     EmailsList.Text= $Action
Strider is online now   Reply With Quote
Unread 19-10-2016, 01:01 PM   #3
Newbie
Thread Starter
 
Join Date: Oct 2016
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0 unixfan is an unknown quantity at this point

AMD Nvidia

Windows 98 / Windows ME Windows NT / Windows 2000 Windows XP Windows Server Windows 7 Windows 10 Linux


Re: Powershell and IE

Excuse me, there is a little error in my script below. I did

$EmailsList=$objIE.document.getElementById("Emails ")

What I observed is, that $objIE.document.getElementById("Emails") does not provide any data, meanwhile the other calls to getElementById provide a data structure.
The only difference is, that one is a hidden input element, the other e select list. Maybe for the access to a select list I have to use a different function ?
unixfan is offline   Reply With Quote
Unread 19-10-2016, 03:26 PM   #4
Webmaster
 
Strider's Avatar
 
Join Date: Nov 2005
Location: Interwebs
Posts: 5,046
Thanks: 637
Thanked 730 Times in 613 Posts
Mood: Busy
Blog Entries: 6
Rep Power: 9045 Strider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly EminentStrider is extemly Eminent

Intel Nvidia

Windows Server Windows 7 Windows 10 Linux


Re: Powershell and IE

Do you have the elementid set for the <select>?

Code:
 <select name="Emails" id="Emails" width="60" STYLE="width: 60px" size="10" />
A few references help you understand Select boxes:

http://www.w3schools.com/jsref/tryit...f_select_value

html - How do I programmatically set the value of a select box element using javascript? - Stack Overflow
Strider is online now   Reply With Quote
Unread 19-10-2016, 07:34 PM   #5
Newbie
Thread Starter
 
Join Date: Oct 2016
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0 unixfan is an unknown quantity at this point

AMD Nvidia

Windows 98 / Windows ME Windows NT / Windows 2000 Windows XP Windows Server Windows 7 Windows 10 Linux


Re: Powershell and IE

Nothing, the object gives me:
Code:
 $objIE.document.getElementById("SubmitTrigger")
  
 tagName                      : INPUT
parentElement                : System.__ComObject
style                        : System.__ComObject
onhelp                       : 
onclick                      :
the object $objIE.document.getElementById("Emails")
nothing. I gave the select an id and a name.

Last edited by Strider; 20-10-2016 at 02:48 PM..
unixfan is offline   Reply With Quote
Unread 19-10-2016, 07:36 PM   #6
Newbie
Thread Starter
 
Join Date: Oct 2016
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0 unixfan is an unknown quantity at this point

AMD Nvidia

Windows 98 / Windows ME Windows NT / Windows 2000 Windows XP Windows Server Windows 7 Windows 10 Linux


Re: Powershell and IE

Sponsored Links
I tried out something else.
Instead of inizialise the list as:

Code:
 <select name="Emails" width="60" STYLE="width: 60px" size="10" />
I do
Code:
 <select name="Emails" id="Emails" width="60" STYLE="width: 60px" size="10" >
        <option value="0"> </option>
</select>
it works as expected. I get an object. I think I had the same problem with Perl, CGI and Javascript. I needed at least ONE element in the list, otherwise it did not work.

Sponsored Links

Last edited by Strider; 20-10-2016 at 02:48 PM..
unixfan is offline   Reply With Quote
Thanked Users:
Strider (20-10-2016)
Reply

Tags
html, internet explorer, javascript, powershell, select list

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing PowerShell dependent features on W2K8 with PowerShell CTP Greg Wojan Microsoft Windows Powershell 12 16-05-2008 01:25 PM
4 the powershell team integrate powershell with onenote pghboemike Microsoft Windows Powershell 2 21-04-2008 01:19 AM
when run powershell script as windows service ,powershell fail powershell fail on winodws 2008 Microsoft Windows Powershell 6 03-02-2008 01:38 PM
Automatic PowerShell Error Parsing in PowerShell Analyzer and PowerShellPlus Karl Prosser[MVP] Microsoft Windows Powershell 0 14-11-2007 09:28 AM
Powershell scripts not working with Vista powershell Ben Microsoft Windows Powershell 20 23-10-2007 10:37 PM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 06:55 PM.


vBulletin, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © 2005-2016, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional