Can anybody tell me if it's possible to rewrite the following javascript snippet in PHP?
var step = new Array();
step[0] = new Array("a","netscape mail","<p>\nOpen Netscape Mail, if you haven't already.<snip!>");
step[1] = new Array("b","message filters dialog","<p>\n Once in the Netscape Mail window, <snip!>");
step[2] = new Array("c","create a new filter","<p>\n Click <code>New<\/code>.<\/p>");
step[3] = new Array("d","set filter conditions","<p>\n Give the new filter a name<snip!>");
step[4] = new Array("e","run filters on folder","<p>\n Your filter is now complete! <snip!>");
buildfaq(step);
// in a separate js file....
function buildfaq(step)
{
for (i=0 ; i<step.length ; i++)
{
document.writeln("<div class=\"slide\" id=\"" + step[i][0] + "\"");
document.writeln("<h3>Step " + (i+1) + " : " + step[i][1] + "</h3>");
document.write(step[i][2]);
document.writeln("</div>");
}
document.getElementById('a').style.display = "block";
document.writeln("</div><!-- end main -->");
document.writeln("<div class=\"sidebar rounded\">");
nav();
document.writeln("</div>");
}
The idea is that for each page I'm building an FAQ. A multidimensional array stores the number of steps, the "title' for each step, and the text body of each step.
The array is used to generate the main body of the page as well as a small navigational box on the right.
Currently with Javascript I'm printing the entire FAQ on the page and hiding it all with CSS, using style.display = "block" to show the next FAQ step. With PHP I would need an extra call to the server, but this is for a local intranet so I'm not worried about traffic load.
I know PHP would need to call the server to reprint the page, but I don't know how to get it to do so. Can anybody get me started?