It is if you need to support JScript in IE8 and earlier.
If you only need to support JavaScript then use the correct JavaScript MIME type instead:
<?php header("Content-type: application/javascript"); ?>
It is if you need to support JScript in IE8 and earlier.
If you only need to support JavaScript then use the correct JavaScript MIME type instead:
<?php header("Content-type: application/javascript"); ?>
Thanks for the reply.
Does this look correct for the file inputJavaScript.js.php
<?php header("Content-type: application/javascript"); ?>
function subjectHandler() {
var subjectArray = [];
var a = true;
document.getElementById('subjectText').innerHTML = "";
document.getElementById('subjectText').innerHTML = "Subject:";
document.getElementById('subject').innerHTML = "";
if(exam.value=="AS"){
subjectArray = <?php echo json_encode($ASsubjects, JSON_PRETTY_PRINT); ?>;
}else if(exam.value=="A2"){
subjectArray = <?php echo json_encode($A2subjects, JSON_PRETTY_PRINT); ?>;
}else if(exam.value=="AP"){
subjectArray = <?php echo json_encode($APsubjects, JSON_PRETTY_PRINT); ?>;
}else if(exam.value=="KET"||exam.value=="PET"||exam.value=="FCE"||exam.value=="IELTS"){
selectOption = "<select name='subject' style='background-color: #FFDDF4'><option value='English'>English</option></select>";
document.getElementById('subject').innerHTML = selectOption;
a = false;
}
if(a){
var strOption = "";
subjectArray.forEach(function(item){
strOption += "<option value='" + item + "'>" + item + "</option>";
});
selectOption = "<select name='subject' style='background-color: #FFDDF4'>" + strOption + "</select>";
document.getElementById('subject').innerHTML = selectOption;
}
}
function sessionHandler() {
var sessionArray = [];
if(exam.value=="AS"|| exam.value=="A2"){
document.getElementById('sessionText').innerHTML = "";
document.getElementById('sessionText').innerHTML = "Session:";
sessionArray = <?php echo json_encode($sessions, JSON_PRETTY_PRINT); ?>;
document.getElementById('session').innerHTML = "";
var strOption = "";
sessionArray.forEach(function(item){
strOption += "<option value='" + item + "'>" + item + "</option>";
});
selectSessionOption = "<select name='session' style='background-color: #FFDDF4'>" + strOption + "</select>";
document.getElementById('session').innerHTML = selectSessionOption;
} else{
document.getElementById('sessionText').innerHTML = "";
document.getElementById('session').innerHTML = "";
}
}
function resultHandler() {
var resultArray = [];
if(exam.value=="AS"|| exam.value=="A2"){
resultArray = <?php echo json_encode($GCEresults, JSON_PRETTY_PRINT); ?>;
}else if(exam.value=="AP"){
resultArray = <?php echo json_encode($APresults, JSON_PRETTY_PRINT); ?>;
}else if(exam.value=="KET"||exam.value=="PET"){
resultArray = <?php echo json_encode($KETPETresults, JSON_PRETTY_PRINT); ?>;/*KET and PET results are same*/
}else if(exam.value=="FCE"){
resultArray = <?php echo json_encode($FCEresults, JSON_PRETTY_PRINT); ?>;
}else if(exam.value=="IELTS"){
resultArray = <?php echo json_encode($IELTSresults, JSON_PRETTY_PRINT); ?>;
}
var strOption = "";
resultArray.forEach(function(item){
strOption += "<option value='" + item + "'>" + item + "</option>";
});
part1Str = "<select name='result";
part2Str = "' style='background-color: #FFDDF4'>" + strOption + "</select>";
}
function yearHandler() {
document.getElementById('yearText').innerHTML = "";
document.getElementById('yearText').innerHTML = "Year:";
var yearArray = [];
yearArray = <?php echo json_encode($years, JSON_PRETTY_PRINT); ?>;
document.getElementById('yearid').innerHTML = "";
var strOption = "";
yearArray.forEach(function(item){
strOption += "<option value='" + item + "'>" + item + "</option>";
});
selectYearOption = "<select name='annual' style='background-color: #FFDDF4'>" + strOption + "</select>";
document.getElementById('yearid').innerHTML = selectYearOption;
}
var i=0;
function classAdder(){
var table = document.getElementById("tableByclass");
var row = document.createElement("tr");
var cell = document.createElement("td");
if(i==0){
var empty = document.createTextNode("First name:");
}else{
var empty = document.createTextNode("");
}
cell.appendChild(empty);
row.appendChild(cell);
cell = document.createElement("td");
var detail = document.createElement("input");
detail.type = "text";
detail.name = "first" +i;
cell.appendChild(detail);
row.appendChild(cell);
cell = document.createElement("td");
if(i==0){
var empty = document.createTextNode("Last name:");
}else{
var empty = document.createTextNode("");
}
cell.appendChild(empty);
row.appendChild(cell);
cell = document.createElement("td");
var detail = document.createElement("input");
detail.type = "text";
detail.name = "last" +i;
cell.setAttribute("id", "idNumber");
cell.appendChild(detail);
row.appendChild(cell);
cell = document.createElement("td");
if(i==0){
var empty = document.createTextNode("Result:");
}else{
var empty = document.createTextNode("");
}
cell.appendChild(empty);
row.appendChild(cell);
cell = document.createElement("td");
cell.setAttribute("class", "left");
selectResultOption = part1Str + i + part2Str;
cell.innerHTML = selectResultOption;
row.appendChild(cell);
table.appendChild(row);
table.rows[1].className = "topRow"; /* second row*/
i++;
}
function clearTable(){
for(var j=i; j>0; j--){
tableByclass.deleteRow(j);
}
i=0;/*resets i to 0 so that when classAdder is called in callFunctions() the first row will include the text nodes First name and Last name*/
}
function callFunctions(){
yearHandler();
subjectHandler();
resultHandler();
sessionHandler();
clearTable();/*clear all but first row*/
classAdder();/*generates last name, first name and result forms when exam type is first pressed*/
}
document.getElementById('exam').onchange = callFunctions;
and the html.php file is,
<!DOCTYPE html>
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/cuislegibney/includes/func.inc.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/cuislegibney/includes/helpers.inc.php';
include $_SERVER['DOCUMENT_ROOT'] . '/cuislegibney/includes/arraybuilder.inc.php';
?>
<html lang="en">
<head>
<link type="text/css" rel="stylesheet" href="/cuislegibney/css/stylesheet.css"/>
<meta charset="utf-8">
<title>Input</title>
</head>
<body>
<link rel="icon" type="image/x-icon" href="/cuislegibney/images/favicon.ico"/>
<header>
<h1>Results archive</h1>
</header>
<div class="input">
<p><a href="/cuislegibney">Return to Main Menu</a></p>
<form action="?<?php htmlout($action);?>" method="post">
<input type="hidden" name="action" value="hauptFormular">
<input type="submit" value="<?php htmlout($button); ?>" >
<table>
<tr>
<td>
<fieldset>
<legend>By class</legend>
<table class="inner" id="tableByclass">
<tr>
<td>Exam type:</td>
<td class="left">
<select name="exam" id="exam" style="background-color: #FFDDF4">
<option></option>
<?php foreach($exams as $key=>$option):
echo "<option value='$key'>$option</option>";
endforeach; ?>
</select></td>
<td id="yearText"></td><td name="yearid" id="yearid" class="left"></td>
<td id="subjectText"></td><td name="subject" id="subject" class="left">to be changed</td>
<td id="sessionText"></td><td name="session" id="session" class="left"></td>
</tr>
</table>
</fieldset>
</td>
</tr>
</table>
<input type="submit" value="<?php htmlout($button); ?>">
<input type="button" onclick="classAdder();" value="Add new student">
</form>
</div>
<script type="text/javascript" src="inputJavaScript.js.php"></script>
<!-- <script type="text/javascript" src="test.js"></script> -->
</body>
</html>
Also the file arraybuilder.inc.php is,
<?php
$exams = ['AS' => 'AS', 'A2' => 'A2', 'AP' => 'AP', 'KET' => 'KET', 'PET' => 'PET', 'FCE' => 'FCE', 'IELTS' => 'IELTS'];
$years = array("2015","2014","2013","2012","2011","2010","2009","2008");
$sessions = array("January","June");
$GCEresults = array("A","B","C","D","E","U");//Will need these as UMS scores
$GCSEresults = array("A","B","C","D","E","U");
$GCSEsubjects = array("Mathematics","Biology");//Will need these as UMS scores
$ASsubjects = array("Mathematics","Geography","Physics","Biology","Chemistry");
$A2subjects = array("Pure Mathematics","Further Mathematics");
$APsubjects = array("Calculus","Chemistry","Physics","Biology");
$APresults = array("5","4","3","2","1");
$KETPETresults = array("Pass","Merit","Distinction");
$FCEresults = array("A","B","C","D");
$IELTSresults = array("1","2","3","4");
Thanks
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.