h8ids
10-26-2006, 03:56 PM
Here's the source code; and it's a lot. :)
Select, Add, Edit and Delete page (Populating, Selecting and Adding to DB works fine. Focusing only on editing records.)
There is a .js include file; code is shown at bottom.
Removed irrelevant code.
Developing for IE and Firefox. My past attempts with multiple FORMS in IE have failed. IE sees the first complete form but wouldn't follow up on the remaining forms.
All-in-one page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<title>Database edit page</title>
<META NAME="EXPIRES" CONTENT="Mon, 01 Jan 2000 12:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script src="javascript.js" type="text/javascript"></script>
</HEAD>
<body marginheight="0" topmargin="0" onload="hidden()">
<!-- Form Border image and -->
<div style="position: absolute; left: 5%;">
<!-- Beginning of form input -->
<div style="position: absolute; width: 580px; left: 60px; top: 40px; z-index:3">
<b>Database edit tool</b>
</div>
<form name="f1" enctype="multipart/form-data" action="dataResolver.php" method="POST">
<!-- Table positioning -->
<div style="position: absolute; width: 635px; left: 40px; top: 85px; z-index:1">
<table width='631' cellspacing='0'>
<thead>
<tr><th colspan="2">Add, Edit or Delete information</th>
</tr>
</thead>
<tr bgcolor='#E0E0E0'>
<!--Second step-->
<td width="481"> Majors: <select name="Major" id="MajorChoice" onchange="show('MajorEdit'); hide('MinorEdit'); hide('ConcenEdit'); hide('TheologyEdit'); hide('MajorAdd'); hide('MinorAdd'); hide('ConcenAdd'); hide('TheologyAdd'); testMajor(this); document.getElementById('MinorChoice').selectedIndex=0; document.getElementById('ConcenChoice').selectedIndex=0; document.getElementById('TheolChoice').selectedIndex=0;"></select></td>
<!-- Add Edit Delete buttons -->
<td width="150">
<input type="button" value="Add" name="MajAdd" id="MajAdd" onclick="show('MajorAdd'); hide('MajorEdit'); hide('TheologyEdit'); hide('ConcenEdit'); hide('ConcenAdd'); hide('MinorEdit'); hide('MinorAdd'); hide('TheologyAdd'); document.getElementById('MajorChoice').selectedIndex=0; document.getElementById('MinorChoice').selectedIndex=0; document.getElementById('ConcenChoice').selectedIndex=0; document.getElementById('TheolChoice').selectedIndex=0">
<input type="button" value="Delete" name="MajorDelete" onclick="resolveData();">
</td>
</tr><tr>
<td>
<div name="MajorAdd" id="MajorAdd" style='display: none'>
<b>Add</b> a Major.
<input type='text' id='Majorcode' name='MajorCode' size='4' maxlength='4'>
<input type='text' id='Majors' name='Majors' size='35' maxlength='50'><br>
<input type="submit" value="Add Major" name="Add Major" title="Add Major" onclick="this.form.action='DBAddMajor.php'"><p>
</div>
<div id="MajorEdit" name="MajorEdit" style='display: none'>
<b>Edit</b> a Major.
<input type="text" name="MajorEdit" id="MajorEdit" size="4" onclick="activeMajorRev()">
<input type="text" name="MajorEdit2" size="35" onclick="activeMajorRev()">
<!-- Record number -->
<input type="text" name="MajorEdit3" id="MajorEdit3" size="3">
<script language="javascript">
function resolveData2(){
var MajorRecords = (document.f1.MajorEdit3.value);
alert(MajorRecords);
}
</script>
<br>
<!--Third step-->
<!--<script type="text/javascript">document.write"-->
<a href="DBEditMajor.php" onclick="this.href+='?position='+resolveData2(); "><input type='button' value='Save revisions' name='MajorRev' id='MajorRev' title='Store Major revisions' style='text-decoration: none' disabled ></a><!--</script>-->
<p></div>
</td>
</tr>
<tr bgcolor='#E0E0E0'>
<td width="481"> Minors: <select name="Minor" id="MinorChoice" onchange="show('MinorEdit'); hide('MajorEdit'); hide('ConcenEdit'); hide('TheologyEdit'); hide('MinorAdd'); hide('MajorAdd'); hide('ConcenAdd'); hide('TheologyAdd'); testMinor(this); document.getElementById('MajorChoice').selectedIndex=0; document.getElementById('ConcenChoice').selectedIndex=0; document.getElementById('TheolChoice').selectedIndex=0"></select></td>
<td width="150">
<!-- Add Edit Delete buttons -->
<input type="button" value="Add" name="MinAdd" id="MinAdd" onclick="show('MinorAdd'); hide('MinorEdit'); hide('TheologyEdit'); hide('ConcenEdit'); hide('ConcenAdd'); hide('MajorEdit'); hide('MajorAdd'); hide('TheologyAdd'); document.getElementById('MajorChoice').selectedIndex=0; document.getElementById('ConcenChoice').selectedIndex=0; document.getElementById('TheolChoice').selectedIndex=0; document.getElementById('MinorChoice').selectedIndex=0">
<input type="button" value="Delete" name="MinorDelete" onclick="resolveData();">
</td>
</tr><tr>
<td>
<div id="MinorAdd" name="MinorAdd" style='display: none'>
<b>Add</b> a Minor.
<input type='text' id='MinorCode' name='MinorCode' size='4' maxlength='4'>
<input type='text' id='Minor' name='Minors' size='35' maxlength='50'><br>
<input type="submit" value="Add Minor" name="Add Minor" title="Add Minor" onclick="this.form.action='DBAddMinor.php'"><p>
</div>
<div id="MinorEdit" name="MinorEdit" style='display: none'>
<b>Edit</b> a Minor.
<input type="text" name="MinorEdit" id="MinorEdit" size="4" onclick="activeMinorRev()">
<input type="text" name="MinorEdit2" size="35" onclick="activeMinorRev()">
<input type="hidden" name="MinorEdit3" size="3"><br>
<input disabled type="submit" value="Save revisions" name="MinorRev" id="MinorRev" title="Store Minor revisions" onclick="this.form.action='DBEditMinor.php'; resolveData();">
<p></div>
</td>
</tr>
<tr bgcolor='#E0E0E0'>
<td width="481"> Concentrations: <select name="Concen" id="ConcenChoice" onchange="show('ConcenEdit'); hide('MajorEdit'); hide('MinorEdit'); hide('TheologyEdit'); hide('ConcenAdd'); hide('MajorAdd'); hide('MinorAdd'); hide('TheologyAdd'); testConcen(this); document.getElementById('MajorChoice').selectedIndex=0; document.getElementById('MinorChoice').selectedIndex=0; document.getElementById('TheolChoice').selectedIndex=0"></select></td>
<td width="150">
<!-- Add Edit Delete buttons -->
<input type="button" value="Add" name="ConcAdd" id="Add" onclick="hide('ConcenEdit'); hide('TheologyEdit'); hide('MinorEdit'); hide('MinorAdd'); hide('MajorEdit'); hide('MajorAdd'); hide('TheologyAdd'); show('ConcenAdd'); document.getElementById('ConcenChoice').selectedIndex=0; document.getElementById('TheolChoice').selectedIndex=0; document.getElementById('MajorChoice').selectedIndex=0; document.getElementById('MinorChoice').selectedIndex=0;">
<input type="button" value="Delete" name="ConcenDelete" onclick="resolveData();">
</td>
</tr><tr>
<td>
<div id="ConcenAdd" name="ConcenAdd" style='display: none'>
<b>Add</b> a Concentration.
<input type='text' id='ConcenCode' name='ConcenCode' size='4' maxlength='4'>
<input type='text' id='Concen' name='Concen' size='35' maxlength='50'><br>
<input type="submit" value="Add Concentration" name="Add Concentration" title="Add Concentration" onclick="this.form.action='DBAddConcen.php'"><p>
</div>
<div id="ConcenEdit" name="ConcenEdit" style='display: none'>
<b>Edit</b> a Concentration.
<input type="text" name="ConcenEdit" id="ConcenEdit" size="4" onclick="activeConcenRev()">
<input type="text" name="ConcenEdit2" size="35" onclick="activeConcenRev()">
<input type="hidden" name="ConcenEdit3" size="3"><br>
<input disabled type="submit" value="Save revisions" name="ConcenRev" id="ConcenRev" title="Store Concentration revisions" onclick="this.form.action='DBEditConcen.php';resolveData();">
<p></div>
</td>
</tr>
<tr bgcolor='#E0E0E0'>
<td width="481"> School of Theology majors: <select name="Theology" id="TheolChoice" onchange="show('TheologyEdit'); hide('ConcenEdit'); hide('MinorEdit'); hide('MajorEdit'); hide('TheologyAdd'); hide('ConcenAdd'); hide('MinorAdd'); hide('MajorAdd'); testTheology(this); document.getElementById('MajorChoice').selectedIndex=0; document.getElementById('MinorChoice').selectedIndex=0; document.getElementById('ConcenChoice').selectedIndex=0"></select></td>
<td width="150">
<!-- Add Edit Delete buttons -->
<input type="button" value="Add" name="TheolAdd" id="Add" onclick="hide('TheologyEdit'); hide('ConcenEdit'); hide('ConcenAdd'); hide('MinorEdit'); hide('MinorAdd'); hide('MajorEdit'); hide('MajorAdd'); show('TheologyAdd'); document.getElementById('TheolChoice').selectedIndex=0; document.getElementById('MajorChoice').selectedIndex=0; document.getElementById('MinorChoice').selectedIndex=0; document.getElementById('ConcenChoice').selectedIndex=0;">
<input type="button" value="Delete" name="TheologyDelete" onclick="resolveData();">
</td>
</tr><tr>
<td>
<div id="TheologyAdd" name="TheologyAdd" style='display: none'>
<b>Add</b> a Theology major.
<input type='text' id='TheologyCode' name='TheologyCode' size='4' maxlength='4'>
<input type='text' id='Theology' name='Theology' size='35' maxlength='50'><br>
<input type="submit" value="Add Theology Major" name="Add Theology Major" title="Add Theology Major" onclick="this.form.action='DBAddTheology.php'"><p>
</div>
<div id="TheologyEdit" name="TheologyEdit" style='display: none'>
<b>Edit</b> a Theology major.
<input type="text" name="TheologyEdit" id="TheologyEdit" size="4" onclick="activeTheolRev()">
<input type="text" name="TheologyEdit2" size="35" onclick="activeTheolRev()">
<input type="hidden" name="TheologyEdit3" size="3"><br>
<input disabled type="submit" value="Save revisions" name="TheolRev" id="TheolRev" title="Store Theology revisions" onclick="this.form.action='DBEditTheology.php'; resolveData();">
<p></div>
</td>
</tr>
<tfoot>
<tr><td colspan='4' > </td></tr>
</tfoot>
</table>
</DIV>
</form>
<script type="text/javascript">
var empMajorChoice = [ ['1','Please Choose One','Please Choose One'],['2','AMST','American Studies'],['3','ANGL','Anglican Studies'],['4','ANTH','Anthropology'],['5','ART','Art'],['6','ARTH','Art History'],['7','ASIA','Asian Studies'],['8','BIBL','Bible'],['9','BIOL','Biology'],['10','CEMT','Christian Ethics Moral Theology'],['11','CHEM','Chemistry'],['12','CHHT','Church History Historical Theology'],['13','CHIN','Chinese'],['14','CLST','Classical Studies'],['15','CSCI','Computer Science'],['16','ECON','Economics'],['17','EDUC','Teacher Education'],['18','ENGL','English'],['19','ENST','Environmental Studies'],['20','FORS','Forestry'],['21','FREN','French'],['22','FRST','French Studies'],['23','GEOL','Geology'],['24','GREK','Greek'],['25','GRMN','German and German Studies'],['26','HIST','History'],['27','HOML','Homiletics'],['28','HUMN','Interdisciplinary Humanities'],['29','ITAL','Italian'],['30','JAPN','Japanese'],['31','LATN','Latin'],['32','LIBR','Library Science'],['33','LTCM','Liturgics and Church Music'],['34','MATH','Mathematics'],['35','MDST','Medieval Studies'],['36','MNST','Ministry Theory and Practice'],['37','MUSC','Music'],['38','NATR','Natural Sciences'],['39','NOND','Non Departmental'],['40','PHED','Physical Education'],['41','PHIL','Philosophy'],['42','PHYS','Physics'],['43','POLS','Political Science'],['44','PSYC','Psychology'],['45','RELG','Religion'],['46','RUSN','Russian'],['47','SPAN','Spanish'],['48','SPRT','Spirituality'],['49','SSFL','Social Science Foreign Language'],['50','STAT','Statistics'],['51','THEO','Theology Systematic'],['52','THTR','Theatre Arts'],['53','TWST','Third World Studies'],['54','WMST','Women Studies'],['55','H8ID','IDs R No Fun'] ];
//Collecting of paired data for Major presentation
for(var a=0;a<empMajorChoice.length;a++){
document.f1.MajorChoice[document.f1.MajorChoice.length] = new Option(empMajorChoice[a][2],empMajorChoice[a][1],empMajorChoice[a][0],empMajorChoice[a][3])
}
var empMinorChoice = [
['1','Please Choose One','Please Choose One'],['2','ANTH','Anthropology'],['3','ARTH','Art History'],['4','ASIA','Asian Studies'],['5','BIOC','BioChemistry'],['6','BIOL','Biology'],['7','CHEM','Chemistry'],['8','CSCI','Computer Science'],['9','ECON','Economics'],['10','ENVS','Environmental Studies'],['11','FINA','Fine Arts'],['12','FREN','French'],['13','FRST','French Studies'],['14','GREK','Greek'],['15','GRMN','German'],['16','HIST','History'],['17','INGS','International and Global Studies'],['18','LATN','Latin'],['19','MACS','Mathematics and Computer Science'],['20','MATH','Mathematics'],['21','MUSC','Music'],['22','PHAS','Physics and Astronomy'],['23','PHIL','Philosophy'],['24','POLS','Political Science'],['25','PSYC','Psychology'],['26','RELG','Religion'],['27','RUSN','Russian'],['28','SPAN','Spanish'],['29','THTR','Theatre Arts'],['30','TWST','Third World Studies'] ];
//Collecting of paired data for Minor presentation
for(var b=0;b<empMinorChoice.length;b++){
document.f1.MinorChoice[document.f1.MinorChoice.length] = new Option(empMinorChoice[b][2],empMinorChoice[b][1],empMinorChoice[b][0],empMinorChoice[b][3])
}
var empConcenChoice = [
['1','','Please Choose One'],['2','EDU','Education'],['3','WMST','Womens Studies'] ];
//Collecting of paired data for Concentration presentation
for(var c=0;c<empConcenChoice.length;c++){
document.f1.ConcenChoice[document.f1.ConcenChoice.length] = new Option(empConcenChoice[c][2],empConcenChoice[c][1],empConcenChoice[c][0],empConcenChoice[c][3])
}
var empTheolChoice = [
['1','','Please Choose One'],['2','BIBL','Bible'],['3','CEMT','Christian Ethics Moral Theology'],['4','CHHT','Church History Historical Theology'],['5','HOML','Homiletics'],['6','LTCM','Liturgics and Church Music'],['7','MNST','Ministry Theory and Practice'],['8','SPRT','Spirituality'],['9','THEO','Theology Systematic'],['15','NEW','THEOLOGY MAJOR IE'] ];
//Collecting of paired data for Theology presentation
for(var d=0;d<empTheolChoice.length;d++){
document.f1.TheolChoice[document.f1.TheolChoice.length] = new Option(empTheolChoice[d][2],empTheolChoice[d][1],empTheolChoice[d][0],empTheolChoice[d][3])
}
</script>
</DIV>
</BODY>
</HTML>
The called page:
<HTML>
<HEAD>
<title>Edit Course Details</title>
<META NAME="EXPIRES" CONTENT="Mon, 01 Jan 2000 12:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script src="javascript.js"></script>
<center><b><noscript><p><br>Please enable JavaScript within your browser so this page will function appropriately.<br>
Then press the browser's refresh button.</noscript></b></center>
</HEAD>
<body>
<script language=javascript>
alert(MajorRecords)
</script>
<!--Drawing information from specified records -->
<br />
<b>Notice</b>: Undefined index: MajorRecords in <b>C:\Program Files\Apache Group\Apache2\htdocs\DBEditMajor.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>: Undefined index: MajorRecords in <b>C:\Program Files\Apache Group\Apache2\htdocs\DBEditMajor.php</b> on line <b>23</b><br />
<br />
<b>Notice</b>: Undefined variable: update in <b>C:\Program Files\Apache Group\Apache2\htdocs\DBEditMajor.php</b> on line <b>27</b><br />
</body>
</HTML>
.js include:
//Revealing edit fields based upon selection
//Major
function hide(){
var MajorEdit = document.getElementById(arguments[0]);
MajorEdit.style.display="none";
}
function show(){
var MajorEdit = document.getElementById(arguments[0]);
MajorEdit.style.display="";
}
//Minor
function hide(){
var MinorEdit = document.getElementById(arguments[0]);
MinorEdit.style.display="none";
}
function show(){
var MinorEdit = document.getElementById(arguments[0]);
MinorEdit.style.display="";
}
//Concentration
function hide(){
var ConcenEdit = document.getElementById(arguments[0]);
ConcenEdit.style.display="none";
}
function show(){
var ConcenEdit = document.getElementById(arguments[0]);
ConcenEdit.style.display="";
}
//Theology
function hide(){
var TheologyEdit = document.getElementById(arguments[0]);
TheologyEdit.style.display="none";
}
function show(){
var TheologyEdit = document.getElementById(arguments[0]);
TheologyEdit.style.display="";
}
//Revision submission button status
function activeMajorRev(){
document.f1.MajorRev.disabled = false;
}
function activeMinorRev(){
document.f1.MinorRev.disabled = false;
}
function activeConcenRev(){
document.f1.ConcenRev.disabled = false;
}
function activeTheolRev(){
document.f1.TheolRev.disabled = false;
}
// Populating Major Edit fields
function testMajor(objMajor){
if(objMajor.selectedIndex!=0){
document.f1.MajorEdit.value=empMajorChoice[objMajor.selectedIndex][1]
document.f1.MajorEdit2.value=empMajorChoice[objMajor.selectedIndex][2]
document.f1.MajorEdit3.value=empMajorChoice[objMajor.selectedIndex][0]
} else {
document.f1.MajorEdit.value="";
document.f1.MajorEdit2.value="";
document.f1.MajorEdit3.value="";
}
}
// Populating Minor fields
function testMinor(objMinor){
if(objMinor.selectedIndex!=0){
document.f1.MinorEdit.value=empMinorChoice[objMinor.selectedIndex][1]
document.f1.MinorEdit2.value=empMinorChoice[objMinor.selectedIndex][2]
document.f1.MinorEdit3.value=empMinorChoice[objMinor.selectedIndex][0]
} else {
document.f1.MinorEdit.value="";
document.f1.MinorEdit2.value="";
document.f1.MinorEdit3.value="";
}
}
// Populating Concentration fields
function testConcen(objConcen){
if(objConcen.selectedIndex!=0){
document.f1.ConcenEdit.value=empConcenChoice[objConcen.selectedIndex][1]
document.f1.ConcenEdit2.value=empConcenChoice[objConcen.selectedIndex][2]
document.f1.ConcenEdit3.value=empConcenChoice[objConcen.selectedIndex][0]
} else {
document.f1.ConcenEdit.value="";
document.f1.ConcenEdit2.value="";
document.f1.ConcenEdit3.value="";
}
}
// Populating Theology fields
function testTheology(objTheology){
if(objTheology.selectedIndex!=0){
document.f1.TheologyEdit.value=empTheolChoice[objTheology.selectedIndex][1]
document.f1.TheologyEdit2.value=empTheolChoice[objTheology.selectedIndex][2]
document.f1.TheologyEdit3.value=empTheolChoice[objTheology.selectedIndex][0]
} else {
document.f1.TheologyEdit.value="";
document.f1.TheologyEdit2.value="";
document.f1.TheologyEdit3.value="";
}
}