Hi;
I am totally new to InfoPath.
I need to accomplish the following:
To create a button or link on an InfoPath template, so when the user clicks on that button it takes the username & password from the page and launches a website and logs in the user.
The website accepts a POST.
I can do it on a regular HTML page with some script that creates a form on the fly and does a submit.
I am trying to use the same script on an InfoPath button but it doesnt work.
What am I doing wrong? is there any other way that I can accomplish what i need?
Pleas help me!
Thank you
Below is my HTML code:
<HTML>
<Head>
<script language="JavaScript">
<!--
function getNewSubmitForm()
{
var submitForm = document.createElement("FORM");
document.body.appendChild(submitForm);
submitForm.method = "POST";
return submitForm;
}
//helper function to add elements to the form
function createNewFormElement(inputForm, elementName, elementValue){
var newElement = document.createElement("input");
inputForm.appendChild(newElement);
newElement.name = elementName;
newElement.type = 'hidden';
newElement.value = elementValue;
return newElement;
}
//function that creates the form, adds some elements
//and then submits it
function sprintLogin()
{
var strUser = document.getElementById('username').value;
var strPassword = document.getElementById('pass').value;
var strLoginMode = 'deepLinkURL';
var strTraget = '/mysprint/pages/secure/SigninServlet?targetPage=/mysprint/pages/sl/global/index.jsp';
var strAction = "https://mysprint.sprint.com/entrycheck/login.fcc";
// alert(strUser);
// alert(strPassword);
var submitForm = getNewSubmitForm();
createNewFormElement(submitForm, "USER", strUser );
createNewFormElement(submitForm, "PASSWORD", strPassword );
createNewFormElement(submitForm, "LOGINMODE", strLoginMode );
createNewFormElement(submitForm, "target", strTraget );
submitForm.action = strAction;
submitForm.submit();
}
-->
</script>
</Head>
<BODY>
User name : <input type="text" name="username" id="username" /><br><br>
Password : <input type="password" name="pass" id="pass" /><br><br><br>
<button type="button" onClick="sprintLogin()">Sprint Login...</button>
</BODY>
</HTML>
The following is the code I am trying to use in InfoPath:
function getNewSubmitForm()
{
var submitForm = XDocument.DOM.createElement("FORM");
XDocument.DOM.appendChild(submitForm);
submitForm.method = "POST";
return submitForm;
}
//helper function to add elements to the form
function createNewFormElement(inputForm, elementName, elementValue){
var newElement =XDocument.DOM.createElement("input");
inputForm.appendChild(newElement);
newElement.name = elementName;
newElement.type = 'hidden';
newElement.value = elementValue;
return newElement;
}
//function that creates the form, adds some elements
//and then submits it
function sprintLogin()
{
//</my:field51>
var strUser = XDocument.DOM.selectSingleNode("//my:field51").text
var strPassword = XDocument.DOM.selectSingleNode("//my:field52").text
var strLoginMode = 'deepLinkURL';
var strTraget = '/mysprint/pages/secure/SigninServlet?targetPage=/mysprint/pages/sl/global/index.jsp';
var strAction = "https://mysprint.sprint.com/entrycheck/login.fcc";
var submitForm = getNewSubmitForm();
createNewFormElement(submitForm, "USER", strUser );
createNewFormElement(submitForm, "PASSWORD", strPassword );
createNewFormElement(submitForm, "LOGINMODE", strLoginMode );
createNewFormElement(submitForm, "target", strTraget );
submitForm.action = strAction;
submitForm.submit();
}
I add code to the OnClick event on the Button to call the SprintLogin() procedure.