I am tryting to automate a repeated task of form filling using HTA. I am opeing the web page into an IFrame. the very First page is the Login page. I am ABLE to access the username and password elements of that page (Displayed in IFrame) easily, and hence able to autologin by clicking a button in HTA. But now, the next page contains a textbox, which i need to fill and then again click a button. Now, i have a button in HTA. When i click this button , i want that the text box should populate with the value i have provided. But instead, i get this error, Unable to set property 'value' of a null reference. On this displaying this object using an alert, it displays 'null'. I am not getting, why i am able to reference the elements on login page and why not on inside pages.
Below is my code :
<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="HTA"
SYSMENU="YES"
NAVIGABLE="YES"
>
<meta http-equiv="x-ua-compatible" content="ie=11">
<title>HTA</title>
<script type="text/javascript">
window.resizeTo(700,700);
</script>
<script type="text/javascript" >
function Start() {
var iframePage = document.getElementById("iframeid").contentDocument;
var userId = iframePage.getElementById("userid");
var passwd = iframePage.getElementById("pwd");
var form = iframePage.getElementById("login");
userId.value='uu';
passwd.value='pp';
form.submit();
}
function Show() {
document.getElementById("iframe").style.display = "block";
}
function FillRncntl() {
var iframePages = document.getElementById("iframeid").contentDocument;;
var runcntl = iframePages.getElementById("PRCSMULTI");
runcntl.value='test';
}
</script>
</head>
<body>
<form class="form" name="form">
<input class="links" type="button" value="Show PIA" onclick="Show();" />
<input class="links" type="button" value="Login" onclick="Start();" />
<input class="links" type="button" value="Enter Runcontrol" onclick="FillRncntl();" />
</form>
<br>
<div class="iframe" id="iframe" style="display:none">
<iframe application="no" src="www.xyz.com" width="600" height="600" id="iframeid">
</div>
</body>
</html>
-Show PIA button shows login page . Working Fine.
-Login button is used to login automatically. Working Fine.
-Enter Runcntl button is used to fill some textbox. NOT Working Fine.
Its not only with this text box, i have same issues with other elemts from this page as well.
PS : Its a Peoplesoft Intranet Website.
PeopleSoft content is contained within an iFrame itself so you need to grab the targetContent iFrame and search for the element in there.
The initial PeopleSoft login page is not displayed within an iFrame.
I changed the last element ID so that this will work on the component: PeopleTools->Process Scheduler->System Process Requests
function FillRncntl() {
var iframePages = document.getElementById("iframeid").contentDocument;
var targetContent = iframePages.getElementById("ptifrmtgtframe").contentDocument;
var runcntl = targetContent.getElementById("PRCSRUNCNTL_RUN_CNTL_ID");
runcntl.value='test';
}