I am trying to create a simple job listing, where users can click on a job title and a page would come up where the job description would be dynamically loaded. I started a thread in xml and someone suggested asking here. Thanks in advance!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<CAREERS>
<JOB>
<TITLE>Director of Sales</TITLE>
<DESC>blah blah blah</DESC>
</JOB>
<JOB>
<TITLE>Graphic Designer</TITLE>
<DESC>blah blah blah</DESC>
</JOB>
<JOB>
<TITLE>Web Developer</TITLE>
<DESC>blah blah blah</DESC>
</JOB>
</CAREERS>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("test.xml");
document.write("<table>");
var x=xmlDoc.getElementsByTagName("JOB");
for (i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td>");
document.write("<a href = 'JobDesc.html'>");
document.write(
x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
document.write("</a>");
document.write("</td>");
}
document.write("</table>");
}
</script>
</body>
</html>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<CAREERS>
<JOB>
<TITLE>Director of Sales</TITLE>
<DESC>Description for Director of Sales</DESC>
</JOB>
<JOB>
<TITLE>Graphic Designer</TITLE>
<DESC>Description for Graphic Designer</DESC>
</JOB>
<JOB>
<TITLE>Web Developer</TITLE>
<DESC>Description for Web Developer</DESC>
</JOB>
</CAREERS>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
#jobs {
position:absolute;
top:100px;
left:100px;
border:thin solid black;
}
#descriptions {
position:absolute;
top:100px;
left:300px;
width:400px;
height:200px;
border:thin solid black;
padding:10px 10px 10px 10px;
}
a {
text-decoration:underline;
}
a:hover {
cursor:pointer;
}
</style>
<script type="text/javascript">
var jobs = new Array();
function setup() {
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("tips.xml");
var jobTitle, jobDesc, tb, row, cell, lnk;
tb = document.getElementById("jobtable");
var jb=xmlDoc.getElementsByTagName("JOB");
for (i=0; i<jb.length; i++) {
jobTitle = jb[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
jobDesc = jb[i].getElementsByTagName("DESC")[0].childNodes[0].nodeValue;
jobs[jobTitle] = jobDesc;
row = tb.insertRow(-1);
cell = row.insertCell(-1)
lnk = document.createElement("a");
lnk.onclick = showJobDescription;
lnk.innerHTML = jobTitle;
cell.appendChild(lnk);
}
}
}
function showJobDescription(ev) {
var src = ev ? ev.target: event.srcElement;
document.getElementById("descriptions").innerHTML = jobs[src.innerHTML];
}
</script>
</head>
<body onload="setup()">
<div id="jobs">
<table id="jobtable">
</table>
</div>
<div id="descriptions"></div>
</body>
</html>