Hi guys,
I need your help.
I need to do some changes to the existing pages. I have an MS access back end database and when i am trying to view the page i recieved the following error:
<b> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
Microsoft ODBC Driver Manager Drivers SQL Set Connection Attribute failed </b>
I already have ODBC connection.
here is my code:
<%
response.buffer = True
'Checks to see if the user clicked the update details or the continue button
'if the update details button was clicked then the user is redirected to the updatestaff.asp page
'otherwise the scripts on this page are used
if request.form("changedetails") = "Yes" then
'save the staffsk as a session variable so that it is available on the updatestaff page
StaffArray = Split(request.form("staff"),"::")
session("staffsk") = StaffArray(0)
response.redirect("updatestaff.asp")
end if
'replace all single quotes with two single quotes inorder for names like o'connell to work in sql
function sqlsafe(str)
sqlsafe = Replace(str, "'", "''")
end function
'define odbc variables
strdsn = "DSN=pd;UID=pd;PWD=pd"
set cn = server.createobject("ADODB.Connection")
set rs = server.createobject("ADODB.Recordset")
cn.open strdsn
if request.form("staff") = "" then
'split staff details from the session variable which was created on the addnew2.asp page
StaffArray = Split(session("newstaff"),"::")
else
'split staff details string from the requesting form on the previous page into the variable StaffArray
session("newstaff") = request.form("staff")
StaffArray = Split(request.form("staff"),"::")
end if
'extract variables from staff array
session("staffsk") = StaffArray(0)
if StaffArray(1) = "0" then
ags = ""
else
ags = StaffArray(1)
end if
surname = StaffArray(2)
givenname = StaffArray(3)
classlevel = StaffArray(4)
session("surname") = surname
session("givenname") = givenname
if StaffArray(5) = "M" then
gender = "Male"
else
gender = "Female"
end if
if StaffArray(6) = "True" then
ATSI = "CHECKED OnClick='this.checked = true;'"
else
ATSI = "UNCHECKED OnClick='this.checked = false;'"
end if
school = StaffArray(7)
if StaffArray(8) = "True" then
NESB = "CHECKED OnClick='this.checked = true;'"
else
NESB = "UNCHECKED OnClick='this.checked = false;'"
end if
if StaffArray(9) = "True" then
disabled = "CHECKED OnClick='this.checked = true;'"
else
disabled = "UNCHECKED OnClick='this.checked = false;'"
end if
%>
<html>
<head>
<title>Add Training To Staff Members Record</title>
<SCRIPT language="JavaScript">
<!--
<!----------FUNCTION USED TO CHECK FOR NUMERICAL ENTRIES------------>
//This function simply uses the isNaN function to see if checkfield is a number
//If an alphabetic character is found the user is warned and the focus returns to the field
function checknumber(textfieldvalue, fieldname)
{
//removes any leading or trailing spaces
textfieldvalue = textfieldvalue.replace(" ","");
if (isNaN(textfieldvalue))
{
alert("Warning!!!\r\nOnly numerical values can be entered\r\n");
document.addtraining.elements[fieldname].focus();
document.addtraining.elements[fieldname].select();
}
}
<!--------CHECK/ADD LEADING ZEROS to DATE FUNCTION--------->
function leadingzero(fieldvalue, formname, fieldname)
{
fieldvalue = fieldvalue.replace(" ","");
if (fieldvalue.length == 1)
{
fieldvalue = '0' + fieldvalue;
document.forms[formname].elements[fieldname].value = fieldvalue;
}
}
<!-----------------AUTO TAB FUNCTION----------------------->
<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
<!---------------VALIDATE DATE FUNCTION------------------->
function validateDate(pDay, pMonth, pYear){
Spaces = / /g
pDay = pDay.replace(Spaces, "");
pMonth = pMonth.replace(Spaces, "");
pYear = pYear.replace(Spaces, "");
<!--Paramater validation methods.-->
if(isNaN(pDay) || isNaN(pMonth) || isNaN(pYear))
return false;
if(pDay.length != 2)
return false;
if(pMonth.length != 2)
return false;
if(pYear.length != 4)
return false;
var leapYear;
var validDate;
var validMonth;
var monthNum = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
var monthDay = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
<!-- triming paramter values -->
pDay *= 1;
pMonth *= 1;
pYear *= 1;
<!-- Check if year is a leap year -->
if(((pYear%4)== 0)&& ((pYear%100) != 0) || ((pYear%400) == 0))
leapYear = true;
else
leapYear = false;
<!-- Check for valid month range 1 - 12 -->
if(pMonth >=1 && pMonth <= 12)
validMonth = true;
else
validMonth = false;
<!-- Check for a valid day range depending if it is a leap year or not -->
switch(leapYear){
case true:
if(validMonth){
switch(pMonth){
case 2:
if(pDay >=1 && pDay <= 29)
validDate = true;
else
validDate = false;
break;
default:
if(pDay >= 1 && pDay <= monthDay[(pMonth-1)])
validDate = true;
else
validDate = false;
break;
}
}
break;
case false:
if(validMonth){
if(pDay >= 1 && pDay <= monthDay[(pMonth-1)])
validDate = true;
else
validDate = false;
}
break;
}
if(!validMonth)
validDate = false;
return (validDate);
}
<!-----------------CHECK DATE ON THE FLY-------------------->
function CheckDateOnTheFly(dday,dmonth,dyear)
{
if (!validateDate(dday, dmonth, dyear))
{
alert("Invalid Date Entered \r\n");
document.addtraining.startd.focus();
document.addtraining.startd.select();
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && document.getElementById) x=document.getElementById; return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function AddProvider()
{
//This function takes that course name and stores it it the querystring
// This is done so that when the page is reloaded the course appears and does not have to be re-entered.
providerlink = 'addprovider.asp?course=';
n = document.addtraining.course.selectedIndex;
//providerlink += document.addtraining.course[n].text;
//providerlink += '&coursevalue=';
providerlink += document.addtraining.course.value;
location.href = providerlink;
}
function CheckData()
{
var error;
nofocus = "yes";
warningmsg = "The Training Details could not be Submitted due to the following errors\r\nPlease fix up the errors and press submit again\r\n\r\n";
if ((document.addtraining.course.value == null) || (document.addtraining.course.value == ""))
{
warningmsg += "- A Course must be entered\r\n";
}
if (document.addtraining.trainschool[0].selected)
{
warningmsg += "- A School/Branch must be selected\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.trainschool.focus();
nofocus = "no";
}
}
if (document.addtraining.programtype[0].selected)
{
warningmsg += "- A Program Type must be selected\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.programtype.focus();
nofocus = "no";
}
}
if ((document.addtraining.startd.value == null || document.addtraining.startd.value == "") || (document.addtraining.startm.value == null || document.addtraining.startm.value == "") || (document.addtraining.starty.value == null || document.addtraining.starty.value == ""))
{
warningmsg += "- A Start Date must be entered\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.startd.focus();
document.addtraining.startd.select();
nofocus = "no";
}
}
else if (!validateDate(document.addtraining.startd.value, document.addtraining.startm.value, document.addtraining.starty.value))
{
warningmsg += "- Invalid Date Entered \r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.startd.focus();
document.addtraining.startd.select();
nofocus = "no";
}
}
if (document.addtraining.funding[0].selected)
{
warningmsg += "- A Funding Source must be selected\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.funding.focus();
nofocus = "no";
}
}
if (error == "yes")
{
alert(warningmsg);
error = "no";
}
else
{
document.addtraining.submit();
error = "no"
}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" text="#FFFFFF" link="#00FFFF" vlink="#00FFFF" alink="#00FFFF" onLoad="MM_preloadImages('images/addtraino.jpg','images/viewreco.jpg','images/changestaffo.jpg','images/backo.jpg','images/newprovidero.jpg')">
<table border="1" cellspacing="0" cellpadding="0" align="center" width="100%">
<tr>
<td bgcolor="#000099" width="100%">
<div align="center">
<h2><font color="#FFFF00">Add Training Details to Staff Members Record</font></h2>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="135">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#6633FF">
<td colspan="3">
<div align="center">
<h2><font color="#FFFFFF"><b>Staff Member Details</b></font></h2>
<font color="#FFFFFF"><i>Information Purposes Only - Staff
details can not be changed on this form.</i></font></div>
</td>
</tr>
<tr bgcolor="#6633FF">
<td>
<div align="center"><b><font color="#FFFFFF">Surname:<br>
<input type="text" name="surname" onFocus="this.blur()" value="<% response.write surname %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">Given Name:<br>
<input type="text" name="givenname" onFocus="this.blur()" value="<% response.write givenname %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">Class Level:<br>
<input type="text" name="classlevel" onFocus="this.blur()" value="<% response.write classlevel %>">
</font></b></div>
</td>
</tr>
<tr bgcolor="#6633FF">
<td>
<div align="center"><b><font color="#FFFFFF">Gender:<br>
<input type="text" name="gender" onFocus="this.blur()" value="<% response.write gender %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">School/Branch:<br>
<input type="text" name="school" onFocus="this.blur()" value="<% response.write school %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">AGS Number:<br>
<input type="text" name="ags" onFocus="this.blur()" value="<% response.write ags %>">
</font></b></div>
</td>
</tr>
<tr bgcolor="#6633FF">
<td><b><font color="#FFFFFF">NESB:
<input type="checkbox" name="nesb" value="checkbox" <% response.write NESB %> >
</font></b></td>
<td><b><font color="#FFFFFF">Disabled:
<input type="checkbox" name="disabled" value="checkbox" <% response.write disabled %>>
</font></b></td>
<td><b><font color="#FFFFFF">ATSI:
<input type="checkbox" name="atsi" value="checkbox" <% response.write ATSI %>>
</font></b></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="addtraining" action="addtraining.asp" method="POST">
<tr>
<td>
<table width="100%" border="2" cellspacing="0" cellpadding="2">
<tr bgcolor="#0066FF">
<td colspan="3"> <div align="center">
<h2><b>Training Details <font color="#FFFFFF">
<input type="hidden" name="staffsk" value"<% response.write StaffSk %>">
</font></b></h2>
<i>Enter Training Details</i> </div></td>
</tr>
<tr bgcolor="#0066FF">
<td width="26%"> <div align="center"><b>Course: </b><i>(required)</i><b><br>
<input name="course" type="text" id="course" tabindex="1" value="<%response.write request.querystring("course") %>" size="40" maxlength="50">
<br>
<br>
</b> </div></td>
<td width="39%"> <div align="center">
<p><b>Provider:</b><br>
<select name="trainprovider" tabindex="2">
<%
'if there is a querystring that is because a course has just been added
'this if statement will determind whether the name of the course which has just been
'added is displayed or Please Select A Provider
if request.querystring("provider") <> "" then
response.write "<option value='" & request.querystring("provider") & "' selected>"& request.querystring("provider") &"</option>"
sql = "SELECT PROVIDER_NAME FROM PROVIDER WHERE PROVIDER_NAME <> '" & sqlsafe(request.querystring("provider")) & "' ORDER BY PROVIDER_NAME"
else
response.write "<option value='NOT_SELECTED' selected><b>Please Select a Provider</b></option>"
sql = "SELECT PROVIDER_NAME FROM PROVIDER ORDER BY PROVIDER_NAME"
end if
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value'" & rs("PROVIDER_NAME") & "'>" & rs("PROVIDER_NAME") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/menuleft2.jpg" width="11" height="34"></td>
<td><a href="javascript:AddProvider();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','images/newprovidero.jpg',1)" target="_self"><img name="Image14" border="0" src="images/newprovider.jpg" width="104" height="34"></a></td>
<td><img src="images/menuright2.jpg" width="11" height="34"></td>
</tr>
</table>
</div></td>
<td width="35%"> <div align="center"><b>Duration </b><i>(Hours)</i><b>:<br>
<input type="text" tabindex="3" name="hours" onBlur="checknumber(this.value, 'hours');">
</b><b><br>
<br>
</b></div>
</td>
</tr>
<tr bgcolor="#0066FF">
<td width="26%">
<div align="center"><b>Program Type: </b><em>(required)</em><b><br>
<select name="programtype" tabindex="4">
<option value="" selected>Please Select a Program Type</option>
<%
sql = "SELECT PROGRAM_TYPE FROM PROGRAM_TYPE ORDER BY PROGRAM_TYPE"
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value'" & rs("program_type") & "'>" & rs("program_type") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
</b><u onclick="MM_openBrWindow('programtypeinfo.asp','ProgramTypeInfo','scrollbars=yes,width=500,height=400')">(Definitions
of Program Types)</u></div></td>
<td width="39%">
<div align="center"><b>School/Branch: </b><i>(required)</i><b><br>
<select name="trainschool" tabindex="5">
<option value="NOT_SELECTED" selected>Please Select
a School/Branch</option>
<%
sql = "SELECT * FROM SCHOOL ORDER BY SCHOOL"
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value='" & rs("school") & "::" & rs("department_sk")&"'>" & rs("school") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
</b><b> <br>
<br>
</b></div></td>
<td width="35%"> <div align="center"><b>Direct Costs: $<br>
<input type="text" name="direct" tabindex="6" onBlur="checknumber(this.value, 'direct');">
<br>
<br>
</b></div></td>
</tr>
<tr bgcolor="#0066FF">
<td width="26%" height="24"> <div align="center"><b>Start
Date: </b><i>(required)</i><b><br>
</b><i>(dd / mm / yyyy)</i><b><br>
<input type="text" tabindex="7" name="startd" size="2" maxlength="2" onkeyup="return autoTab(this, 2, event);" onblur="leadingzero(this.value, 'addtraining', 'startd')">
/
<input type="text" tabindex="8" name="startm" size="2" maxlength="2" onkeyup="return autoTab(this, 2, event);" onblur="leadingzero(this.value, 'addtraining', 'startm')">
/
<input type="text" tabindex="9" name="starty" size="4" maxlength="4" onkeyup="return autoTab(this, 4, event);" onblur="CheckDateOnTheFly(document.addtraining.startd.value,document.addtraining.startm.value,document.addtraining.starty.value)">
</b></div></td>
<td width="39%" height="24"> <div align="center"><b>Funding
Source: </b><em>(required)</em><b><br>
<select name="funding" tabindex="10">
<option value="" selected>Please Select a Funding Source</option>
<%
sql = "SELECT FUND_SOURCE FROM FUND_SOURCE ORDER BY FUND_SOURCE"
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value'" & rs("FUND_SOURCE") & "'>" & rs("FUND_SOURCE") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
<br>
<br>
</b></div></td>
<td width="35%" height="24"><div align="center"><b><br>
</b></div></td>
</tr>
<tr bgcolor="#0066FF">
<td colspan="3"> <div align="center"></div>
<div align="center"><br>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><img src="images/menuleft2.jpg" width="11" height="34"></td>
<td><a href="JavaScript:CheckData();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','images/addtraino.jpg',1)"><img name="Image3" border="0" src="images/addtrain.jpg" width="153" height="34" tabindex="13"></a></td>
<td><img src="images/menuright2.jpg" width="11" height="34"></td>
</tr>
</table>
</div></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<br>
<form name="viewrecords" method="POST" action="viewrecords">
<b><font color="#FFFFFF"> </font></b>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><img src="images/menuleft.jpg" width="11" height="34"></td>
<td><a href="listpd.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','images/viewreco.jpg',1)"><img name="Image6" border="0" src="images/viewrec.jpg" width="296" height="34"></a></td>
<td><a href="pd1.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','images/changestaffo.jpg',1)" target="_self"><img name="Image7" border="0" src="images/changestaff.jpg" width="212" height="34"></a></td>
<td><a href="javascript:history.back();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','images/backo.jpg',1)"><img name="Image11" border="0" src="images/back.jpg" width="48" height="34"></a></td>
<td><img src="images/menuright.jpg" width="11" height="34"></td>
</tr>
</table>
<b><font color="#FFFFFF">
<input type="hidden" name="staffsk" value"<% response.write StaffSk %>">
</font></b>
</form>
<a href="logout.asp" target="_self">Exit Professional Development Online
Database</a> </div>
</td>
</tr>
</table>
</body>
</html>
I need your help.
I need to do some changes to the existing pages. I have an MS access back end database and when i am trying to view the page i recieved the following error:
<b> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
Microsoft ODBC Driver Manager Drivers SQL Set Connection Attribute failed </b>
I already have ODBC connection.
here is my code:
<%
response.buffer = True
'Checks to see if the user clicked the update details or the continue button
'if the update details button was clicked then the user is redirected to the updatestaff.asp page
'otherwise the scripts on this page are used
if request.form("changedetails") = "Yes" then
'save the staffsk as a session variable so that it is available on the updatestaff page
StaffArray = Split(request.form("staff"),"::")
session("staffsk") = StaffArray(0)
response.redirect("updatestaff.asp")
end if
'replace all single quotes with two single quotes inorder for names like o'connell to work in sql
function sqlsafe(str)
sqlsafe = Replace(str, "'", "''")
end function
'define odbc variables
strdsn = "DSN=pd;UID=pd;PWD=pd"
set cn = server.createobject("ADODB.Connection")
set rs = server.createobject("ADODB.Recordset")
cn.open strdsn
if request.form("staff") = "" then
'split staff details from the session variable which was created on the addnew2.asp page
StaffArray = Split(session("newstaff"),"::")
else
'split staff details string from the requesting form on the previous page into the variable StaffArray
session("newstaff") = request.form("staff")
StaffArray = Split(request.form("staff"),"::")
end if
'extract variables from staff array
session("staffsk") = StaffArray(0)
if StaffArray(1) = "0" then
ags = ""
else
ags = StaffArray(1)
end if
surname = StaffArray(2)
givenname = StaffArray(3)
classlevel = StaffArray(4)
session("surname") = surname
session("givenname") = givenname
if StaffArray(5) = "M" then
gender = "Male"
else
gender = "Female"
end if
if StaffArray(6) = "True" then
ATSI = "CHECKED OnClick='this.checked = true;'"
else
ATSI = "UNCHECKED OnClick='this.checked = false;'"
end if
school = StaffArray(7)
if StaffArray(8) = "True" then
NESB = "CHECKED OnClick='this.checked = true;'"
else
NESB = "UNCHECKED OnClick='this.checked = false;'"
end if
if StaffArray(9) = "True" then
disabled = "CHECKED OnClick='this.checked = true;'"
else
disabled = "UNCHECKED OnClick='this.checked = false;'"
end if
%>
<html>
<head>
<title>Add Training To Staff Members Record</title>
<SCRIPT language="JavaScript">
<!--
<!----------FUNCTION USED TO CHECK FOR NUMERICAL ENTRIES------------>
//This function simply uses the isNaN function to see if checkfield is a number
//If an alphabetic character is found the user is warned and the focus returns to the field
function checknumber(textfieldvalue, fieldname)
{
//removes any leading or trailing spaces
textfieldvalue = textfieldvalue.replace(" ","");
if (isNaN(textfieldvalue))
{
alert("Warning!!!\r\nOnly numerical values can be entered\r\n");
document.addtraining.elements[fieldname].focus();
document.addtraining.elements[fieldname].select();
}
}
<!--------CHECK/ADD LEADING ZEROS to DATE FUNCTION--------->
function leadingzero(fieldvalue, formname, fieldname)
{
fieldvalue = fieldvalue.replace(" ","");
if (fieldvalue.length == 1)
{
fieldvalue = '0' + fieldvalue;
document.forms[formname].elements[fieldname].value = fieldvalue;
}
}
<!-----------------AUTO TAB FUNCTION----------------------->
<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
<!---------------VALIDATE DATE FUNCTION------------------->
function validateDate(pDay, pMonth, pYear){
Spaces = / /g
pDay = pDay.replace(Spaces, "");
pMonth = pMonth.replace(Spaces, "");
pYear = pYear.replace(Spaces, "");
<!--Paramater validation methods.-->
if(isNaN(pDay) || isNaN(pMonth) || isNaN(pYear))
return false;
if(pDay.length != 2)
return false;
if(pMonth.length != 2)
return false;
if(pYear.length != 4)
return false;
var leapYear;
var validDate;
var validMonth;
var monthNum = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
var monthDay = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
<!-- triming paramter values -->
pDay *= 1;
pMonth *= 1;
pYear *= 1;
<!-- Check if year is a leap year -->
if(((pYear%4)== 0)&& ((pYear%100) != 0) || ((pYear%400) == 0))
leapYear = true;
else
leapYear = false;
<!-- Check for valid month range 1 - 12 -->
if(pMonth >=1 && pMonth <= 12)
validMonth = true;
else
validMonth = false;
<!-- Check for a valid day range depending if it is a leap year or not -->
switch(leapYear){
case true:
if(validMonth){
switch(pMonth){
case 2:
if(pDay >=1 && pDay <= 29)
validDate = true;
else
validDate = false;
break;
default:
if(pDay >= 1 && pDay <= monthDay[(pMonth-1)])
validDate = true;
else
validDate = false;
break;
}
}
break;
case false:
if(validMonth){
if(pDay >= 1 && pDay <= monthDay[(pMonth-1)])
validDate = true;
else
validDate = false;
}
break;
}
if(!validMonth)
validDate = false;
return (validDate);
}
<!-----------------CHECK DATE ON THE FLY-------------------->
function CheckDateOnTheFly(dday,dmonth,dyear)
{
if (!validateDate(dday, dmonth, dyear))
{
alert("Invalid Date Entered \r\n");
document.addtraining.startd.focus();
document.addtraining.startd.select();
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && document.getElementById) x=document.getElementById; return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function AddProvider()
{
//This function takes that course name and stores it it the querystring
// This is done so that when the page is reloaded the course appears and does not have to be re-entered.
providerlink = 'addprovider.asp?course=';
n = document.addtraining.course.selectedIndex;
//providerlink += document.addtraining.course[n].text;
//providerlink += '&coursevalue=';
providerlink += document.addtraining.course.value;
location.href = providerlink;
}
function CheckData()
{
var error;
nofocus = "yes";
warningmsg = "The Training Details could not be Submitted due to the following errors\r\nPlease fix up the errors and press submit again\r\n\r\n";
if ((document.addtraining.course.value == null) || (document.addtraining.course.value == ""))
{
warningmsg += "- A Course must be entered\r\n";
}
if (document.addtraining.trainschool[0].selected)
{
warningmsg += "- A School/Branch must be selected\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.trainschool.focus();
nofocus = "no";
}
}
if (document.addtraining.programtype[0].selected)
{
warningmsg += "- A Program Type must be selected\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.programtype.focus();
nofocus = "no";
}
}
if ((document.addtraining.startd.value == null || document.addtraining.startd.value == "") || (document.addtraining.startm.value == null || document.addtraining.startm.value == "") || (document.addtraining.starty.value == null || document.addtraining.starty.value == ""))
{
warningmsg += "- A Start Date must be entered\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.startd.focus();
document.addtraining.startd.select();
nofocus = "no";
}
}
else if (!validateDate(document.addtraining.startd.value, document.addtraining.startm.value, document.addtraining.starty.value))
{
warningmsg += "- Invalid Date Entered \r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.startd.focus();
document.addtraining.startd.select();
nofocus = "no";
}
}
if (document.addtraining.funding[0].selected)
{
warningmsg += "- A Funding Source must be selected\r\n";
error = "yes";
if (nofocus == "yes")
{
document.addtraining.funding.focus();
nofocus = "no";
}
}
if (error == "yes")
{
alert(warningmsg);
error = "no";
}
else
{
document.addtraining.submit();
error = "no"
}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" text="#FFFFFF" link="#00FFFF" vlink="#00FFFF" alink="#00FFFF" onLoad="MM_preloadImages('images/addtraino.jpg','images/viewreco.jpg','images/changestaffo.jpg','images/backo.jpg','images/newprovidero.jpg')">
<table border="1" cellspacing="0" cellpadding="0" align="center" width="100%">
<tr>
<td bgcolor="#000099" width="100%">
<div align="center">
<h2><font color="#FFFF00">Add Training Details to Staff Members Record</font></h2>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="135">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#6633FF">
<td colspan="3">
<div align="center">
<h2><font color="#FFFFFF"><b>Staff Member Details</b></font></h2>
<font color="#FFFFFF"><i>Information Purposes Only - Staff
details can not be changed on this form.</i></font></div>
</td>
</tr>
<tr bgcolor="#6633FF">
<td>
<div align="center"><b><font color="#FFFFFF">Surname:<br>
<input type="text" name="surname" onFocus="this.blur()" value="<% response.write surname %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">Given Name:<br>
<input type="text" name="givenname" onFocus="this.blur()" value="<% response.write givenname %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">Class Level:<br>
<input type="text" name="classlevel" onFocus="this.blur()" value="<% response.write classlevel %>">
</font></b></div>
</td>
</tr>
<tr bgcolor="#6633FF">
<td>
<div align="center"><b><font color="#FFFFFF">Gender:<br>
<input type="text" name="gender" onFocus="this.blur()" value="<% response.write gender %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">School/Branch:<br>
<input type="text" name="school" onFocus="this.blur()" value="<% response.write school %>">
</font></b></div>
</td>
<td>
<div align="center"><b><font color="#FFFFFF">AGS Number:<br>
<input type="text" name="ags" onFocus="this.blur()" value="<% response.write ags %>">
</font></b></div>
</td>
</tr>
<tr bgcolor="#6633FF">
<td><b><font color="#FFFFFF">NESB:
<input type="checkbox" name="nesb" value="checkbox" <% response.write NESB %> >
</font></b></td>
<td><b><font color="#FFFFFF">Disabled:
<input type="checkbox" name="disabled" value="checkbox" <% response.write disabled %>>
</font></b></td>
<td><b><font color="#FFFFFF">ATSI:
<input type="checkbox" name="atsi" value="checkbox" <% response.write ATSI %>>
</font></b></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="addtraining" action="addtraining.asp" method="POST">
<tr>
<td>
<table width="100%" border="2" cellspacing="0" cellpadding="2">
<tr bgcolor="#0066FF">
<td colspan="3"> <div align="center">
<h2><b>Training Details <font color="#FFFFFF">
<input type="hidden" name="staffsk" value"<% response.write StaffSk %>">
</font></b></h2>
<i>Enter Training Details</i> </div></td>
</tr>
<tr bgcolor="#0066FF">
<td width="26%"> <div align="center"><b>Course: </b><i>(required)</i><b><br>
<input name="course" type="text" id="course" tabindex="1" value="<%response.write request.querystring("course") %>" size="40" maxlength="50">
<br>
<br>
</b> </div></td>
<td width="39%"> <div align="center">
<p><b>Provider:</b><br>
<select name="trainprovider" tabindex="2">
<%
'if there is a querystring that is because a course has just been added
'this if statement will determind whether the name of the course which has just been
'added is displayed or Please Select A Provider
if request.querystring("provider") <> "" then
response.write "<option value='" & request.querystring("provider") & "' selected>"& request.querystring("provider") &"</option>"
sql = "SELECT PROVIDER_NAME FROM PROVIDER WHERE PROVIDER_NAME <> '" & sqlsafe(request.querystring("provider")) & "' ORDER BY PROVIDER_NAME"
else
response.write "<option value='NOT_SELECTED' selected><b>Please Select a Provider</b></option>"
sql = "SELECT PROVIDER_NAME FROM PROVIDER ORDER BY PROVIDER_NAME"
end if
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value'" & rs("PROVIDER_NAME") & "'>" & rs("PROVIDER_NAME") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/menuleft2.jpg" width="11" height="34"></td>
<td><a href="javascript:AddProvider();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','images/newprovidero.jpg',1)" target="_self"><img name="Image14" border="0" src="images/newprovider.jpg" width="104" height="34"></a></td>
<td><img src="images/menuright2.jpg" width="11" height="34"></td>
</tr>
</table>
</div></td>
<td width="35%"> <div align="center"><b>Duration </b><i>(Hours)</i><b>:<br>
<input type="text" tabindex="3" name="hours" onBlur="checknumber(this.value, 'hours');">
</b><b><br>
<br>
</b></div>
</td>
</tr>
<tr bgcolor="#0066FF">
<td width="26%">
<div align="center"><b>Program Type: </b><em>(required)</em><b><br>
<select name="programtype" tabindex="4">
<option value="" selected>Please Select a Program Type</option>
<%
sql = "SELECT PROGRAM_TYPE FROM PROGRAM_TYPE ORDER BY PROGRAM_TYPE"
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value'" & rs("program_type") & "'>" & rs("program_type") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
</b><u onclick="MM_openBrWindow('programtypeinfo.asp','ProgramTypeInfo','scrollbars=yes,width=500,height=400')">(Definitions
of Program Types)</u></div></td>
<td width="39%">
<div align="center"><b>School/Branch: </b><i>(required)</i><b><br>
<select name="trainschool" tabindex="5">
<option value="NOT_SELECTED" selected>Please Select
a School/Branch</option>
<%
sql = "SELECT * FROM SCHOOL ORDER BY SCHOOL"
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value='" & rs("school") & "::" & rs("department_sk")&"'>" & rs("school") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
</b><b> <br>
<br>
</b></div></td>
<td width="35%"> <div align="center"><b>Direct Costs: $<br>
<input type="text" name="direct" tabindex="6" onBlur="checknumber(this.value, 'direct');">
<br>
<br>
</b></div></td>
</tr>
<tr bgcolor="#0066FF">
<td width="26%" height="24"> <div align="center"><b>Start
Date: </b><i>(required)</i><b><br>
</b><i>(dd / mm / yyyy)</i><b><br>
<input type="text" tabindex="7" name="startd" size="2" maxlength="2" onkeyup="return autoTab(this, 2, event);" onblur="leadingzero(this.value, 'addtraining', 'startd')">
/
<input type="text" tabindex="8" name="startm" size="2" maxlength="2" onkeyup="return autoTab(this, 2, event);" onblur="leadingzero(this.value, 'addtraining', 'startm')">
/
<input type="text" tabindex="9" name="starty" size="4" maxlength="4" onkeyup="return autoTab(this, 4, event);" onblur="CheckDateOnTheFly(document.addtraining.startd.value,document.addtraining.startm.value,document.addtraining.starty.value)">
</b></div></td>
<td width="39%" height="24"> <div align="center"><b>Funding
Source: </b><em>(required)</em><b><br>
<select name="funding" tabindex="10">
<option value="" selected>Please Select a Funding Source</option>
<%
sql = "SELECT FUND_SOURCE FROM FUND_SOURCE ORDER BY FUND_SOURCE"
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value'" & rs("FUND_SOURCE") & "'>" & rs("FUND_SOURCE") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
<br>
<br>
</b></div></td>
<td width="35%" height="24"><div align="center"><b><br>
</b></div></td>
</tr>
<tr bgcolor="#0066FF">
<td colspan="3"> <div align="center"></div>
<div align="center"><br>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><img src="images/menuleft2.jpg" width="11" height="34"></td>
<td><a href="JavaScript:CheckData();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','images/addtraino.jpg',1)"><img name="Image3" border="0" src="images/addtrain.jpg" width="153" height="34" tabindex="13"></a></td>
<td><img src="images/menuright2.jpg" width="11" height="34"></td>
</tr>
</table>
</div></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<br>
<form name="viewrecords" method="POST" action="viewrecords">
<b><font color="#FFFFFF"> </font></b>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><img src="images/menuleft.jpg" width="11" height="34"></td>
<td><a href="listpd.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','images/viewreco.jpg',1)"><img name="Image6" border="0" src="images/viewrec.jpg" width="296" height="34"></a></td>
<td><a href="pd1.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','images/changestaffo.jpg',1)" target="_self"><img name="Image7" border="0" src="images/changestaff.jpg" width="212" height="34"></a></td>
<td><a href="javascript:history.back();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','images/backo.jpg',1)"><img name="Image11" border="0" src="images/back.jpg" width="48" height="34"></a></td>
<td><img src="images/menuright.jpg" width="11" height="34"></td>
</tr>
</table>
<b><font color="#FFFFFF">
<input type="hidden" name="staffsk" value"<% response.write StaffSk %>">
</font></b>
</form>
<a href="logout.asp" target="_self">Exit Professional Development Online
Database</a> </div>
</td>
</tr>
</table>
</body>
</html>