|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| 11/03/2009 at 08:37PM PST, ID: 24869781 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: |
<html>
<script>
/*****************************************
File: asgn6_kennedy.htm
Author: John Kennedy
Assignment: 6
Create Date:
Last Modified:
****************************************/
</script>
<head>
<title>AJAX Finances Logon</title>
<style>
div.AcctInfo
{
position: absolute;
left: 100px;
top: 300px;
height: 400px;
width: 1024px;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<script language = "JavaScript">
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest)
{
XMLHttpRequestObject = new XMLHttpRequest();
if(XMLHttpRequestObject.overrideMimeType)
{
XMLHttpRequestObject.overrideMimeType("text/xml");
}
}
else if (window.ActiveXObject)
{
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
function getXML(dataSource, divID, data)
{
if(XMLHttpRequestObject)
{
var obj = document.getElementById(divID);
obj.innerHTML = "Loading...";
XMLHttpRequestObject.open("POST", dataSource);
XMLHttpRequestObject.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200)
{
var myXML = XMLHttpRequestObject.responseXML;
obj.innerHTML = "";
displayXML(myXML);
}
}
XMLHttpRequestObject.send("data=" + data);
}
return false;
}
function displayXML(myXML)
{
var XMLLogonElements = myXML.getElementsByTagName("logon");
var myLogon = XMLLogonElements[0].firstChild.data;
var XMLCategoryElements = myXML.getElementsByTagName("category");
// var XMLTransElements = myXML.getElementsByTagName("trans");
var targetDiv = document.getElementById("targetDiv");
if (myLogon == "Success")
{
var logonForm = document.getElementById("logon_form");
logonForm.style.visibilty = "hidden";
var resultString = "<h1>Finances</h1> \
Select Category: \
<select id='myaccts' onchange=getAcctInfo('http://ntowl.com/testfiles/AJAXPHP/displayTrans_detailsXML.php')> \
<option value='-'>-</option>";
for(i = 0; i < XMLCategoryElements.length; i++)
{
resultString += "<option value= " + XMLCategoryElements[i].firstChild.data + "> \
" + XMLCategoryElements[i].firstChild.data + "</option>";
}
resultString += "</select>"
logonForm.innerHTML = resultString;
}
else if(myLogon == "Error")
{
targetDiv.innerHTML = "<font color=red>Error: You have input an incorrect username or password</font>";
}
else if(myLogon == "Trans")
{
var myDataNode = myXML.documentElement;
var logonNode = myDataNode.firstChild;
var transNode = logonNode.firstChild;
// alert(myDataNode);
// alert(logonNode);
// alert(transNode.attributes);
attributes = transNode.attributes;
myDate = attributes.getNamedItem("date");
getIncExp = attributes.getNamedItem("incexp");
getItem = attributes.getNamedItem("item");
getAmount = attributes.getNamedItem("amount");
var myTable = "\n<hr><table border=1>\n";
myTable += "<tr><th>Item</th> \
<th>Inc/Exp</th> \
<th>Item</th> \
<th>Amount</th></tr>";
/*
for(rows = 0; rows < XMLTransElements.length; rows++)
{
myTable += "<tr>" + XMLTransElements[rows].firstChild.data + "</tr>";
}
*/
myTable += "</table>";
objAcctInfo = document.getElementById("AcctInfo");
objAcctInfo.innerHTML = myTable;
}
}
function validateLogon(dataSource, divID)
{
var userName = document.getElementById("userid").value;
var passWord = document.getElementById("password").value;
var data = userName + "|" + passWord;
getXML(dataSource, divID, data);
return false;
}
function getAcctInfo(dataSource)
{
var data = document.getElementById("myaccts").value;
var divID = "AcctInfo";
getXML(dataSource, divID, data);
}
</script>
<body bgcolor="#c0c0c0">
<div id="logon_form">
<h2>Logon</h2>
<form name="form">
<table>
<tr>
<td>Userid:
<td><input type="text" name="userid" id="userid">
</tr>
<tr>
<td>Password:
<td><input type="password" name="password" id="password">
</tr>
<tr>
<td><br><input type=submit value="Logon"
onclick="return validateLogon('http://ntowl.com/testfiles/AJAXPHP/validate_logonxml_accounts.php', 'targetDiv')">
</tr>
</table>
</form>
</div>
<div id="AcctInfo"></div>
<div id="targetDiv"></div>
</body>
</html>
|
Advertisement