jeudi 20 octobre 2016

Object Expected when Targeting CheckBox Value

I have the following script, which successfully changes the value of a checkbox (this toggles whether or not the user in in a certain skype response group):

var ie = WSH.CreateObject('InternetExplorer.Application');
    url = "http://ift.tt/2e8Q1XU",

ie.visible = true;
ie.Navigate(url);
while (ie.readyState != 4) WSH.Sleep(25);

var element = ie.document.getElementById('ctl05_ctl00_ctl04_ctl00_ctl00_ctl01');
element.click();
WSH.Sleep(25);

ie.quit()

I would like to incorporate a simple message confirming to the user whether or not it worked:

var element = ie.document.getElementById('ctl05_ctl00_ctl04_ctl00_ctl00_ctl01');
var value = element.value;
alert(value);

But I see this error on the line with alert(value);

Script: C:\Users\User.Name\Source\Repos\Scripts\Useful\Toggle-ITSupportResponseGroup.js

Line: 14

Char: 1

Error: Object expected

Code: 800A138F

Source: Microsoft JScript runtime error

Here is the html for the checkbox:

<INPUT onclick="javascript:setTimeout('__doPostBack(\'ctl05$ctl00$ctl04$ctl00$ctl00$ctl01\',\'\')', 0)" 
    id=ctl05_ctl00_ctl04_ctl00_ctl00_ctl01 
    type=checkbox value="" 
    name=ctl05$ctl00$ctl04$ctl00$ctl00$ctl01>

With value="on" and CHECKED="checked" if the checkbox is active.

Why am i seeing this error?




Aucun commentaire:

Enregistrer un commentaire