Put the following code inside a slide.htt page in order to have quick navigation between pages using a drop-down navigation box. First we define a practical function that builds the <option> tags for the "select" component:
<%
/* Generate drop box options for quick navigation */
String addLinks() {
StringBuffer buf = new StringBuffer();
for (int i=0; i<files.length; i++) {
if (files[i].isDirectory()) continue;
String base = files[i].getName();
int lastDot = base.lastIndexOf('.');
if (lastDot != -1) base = base.substring(0,lastDot);
buf.append("<option");
if (i == imageNum-1) buf.append(" selected");
buf.append(" value=\"" + base+".html" + "\">" + base);
}
return buf.toString();
}
%>
Now it's easy to generate the navigation list:
<form>
<select onChange="window.location.href = this.options\[this.selectedIndex].value">
<%= addLinks() %>
</select>
</form>