I have the following script from Javascriptsource that relates to a condtional menu form created in the body.
Thanks to vibris I can now call the head script so I only need to edit it once in the source file. How can I can do the same for the body calling the form into a table on the page, so I only need to edit this source file for each menu1 option.
I have managed to get it show the tag referring to the script but unfortunately it doesnt reproduce the form on the page.
This is for a school site and I would really appreciate some help. The full script is below including the body section.
It remains in its unedited form.
Many thanks in advance
<!-- TWO STEPS TO INSTALL DOUBLE MENU:
1. Copy the first coding into the HEAD of your HTML document
2. Add the second code into the BODY of your HTML document -->
<!-- STEP ONE: Add this code into the BODY of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
v=false;
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
if (typeof(Option)+"" != "undefined"
v=true;
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: webreference.com -->
<!-- Web Site: -->;
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->
<!-- Begin
if(v){a=new Array();aln=0;}
function getFormNum (formName) {
formNum =-1;
for (i=0;i<document.forms.length;i++){
tempForm = document.forms;
if (formName == tempForm) {
formNum = i;
correctForm = tempForm;
break;
}
}
return formNum;
}
function jmp(formName,elementNum) {
getFormNum(formName);
if (formNum>=0) {
with (document.forms[formNum].elements[elementNum]) {
i=selectedIndex;
if (i>=0) location=options.value;
}
}
}
function O(txt,url) {
a[k]=new Option(txt,url);k++;
}
function relate(formName,elementNum,j) {
if(v) {
k=1;
if(j==0) { // default category item
a=new Array();
O("Pick Item --->",""
;
}
if(j==1) { // 1st category items
a=new Array();
O("Pick Item --->",""
;
O("Buttons","O("Clocks","O("Cookies","O("Forms","O("Games","O("Messages","O("Miscellaneous","O("Navigation","O("Page Details","O("Pass. Protec.","O("Scrolls","O("User Details","O("Table Of Contents","}
if(j==2) { // 2nd category items
a=new Array();
O("Pick Item --->",""
;
O("How Do I...?","O("Script Help","O("Script Requests","O("Intro to JavaScript","O("What's New?","}
if(j==3) { // 3rd category items
a=new Array();
O("Pick Item --->",""
;
O("JS Question?","O("JS Contribution","O("Site Comments","O("Other ...","}
aln2=a.length;
getFormNum(formName);
if (formNum>=0) {
formNum = formNum + 1;
with (document.forms[formNum].elements[elementNum]) {
for (var i=options.length-1;i>0;i--) options=null;
for (var i=1;i<aln2;i++) options[i-1]=a;
options[0].selected=true;
}
}
} else {
jmp(formName,elementNum);
}
}
// End -->
</SCRIPT>
</head>
<!-- STEP TWO: Put this code into the BODY of your HTML document -->
<BODY>
<center>
<table border=0>
<tr valign=top>
<TD align=center><form name=f1 method=post action="" onSubmit="return false;">
<select name=m1 onChange="relate(this.form,0,this.selectedIndex); document.f2.m2.focus();">
<option value="/">Pick Category --->
<option value="/">JavaScripts
<option value="/">Message Forum
<option value="/">Feedback Form
</select></form></td>
<td align=center> <b>then</b> </td>
<td><form name=f2 method=post action="" onsubmit="return false;">
<select name="m2" onchange="jmp(this.form,0)">
<option value="/">Pick Item --->
<!--
Put a blank item (like below) for the MAXIMUM
number of items in one of your categories.
i.e. If your "largest" menu contains 5 items,
include 5 blank lines here. For 10, include
10, and so on.
-->
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
</select></form></td>
</tr>
</table>
</center>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href=" JavaScript Source</a></font>
</center><p>
<!-- Script Size: 4.56 KB -->
Thanks to vibris I can now call the head script so I only need to edit it once in the source file. How can I can do the same for the body calling the form into a table on the page, so I only need to edit this source file for each menu1 option.
I have managed to get it show the tag referring to the script but unfortunately it doesnt reproduce the form on the page.
This is for a school site and I would really appreciate some help. The full script is below including the body section.
It remains in its unedited form.
Many thanks in advance
<!-- TWO STEPS TO INSTALL DOUBLE MENU:
1. Copy the first coding into the HEAD of your HTML document
2. Add the second code into the BODY of your HTML document -->
<!-- STEP ONE: Add this code into the BODY of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
v=false;
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
if (typeof(Option)+"" != "undefined"
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: webreference.com -->
<!-- Web Site: -->;
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->
<!-- Begin
if(v){a=new Array();aln=0;}
function getFormNum (formName) {
formNum =-1;
for (i=0;i<document.forms.length;i++){
tempForm = document.forms;
if (formName == tempForm) {
formNum = i;
correctForm = tempForm;
break;
}
}
return formNum;
}
function jmp(formName,elementNum) {
getFormNum(formName);
if (formNum>=0) {
with (document.forms[formNum].elements[elementNum]) {
i=selectedIndex;
if (i>=0) location=options.value;
}
}
}
function O(txt,url) {
a[k]=new Option(txt,url);k++;
}
function relate(formName,elementNum,j) {
if(v) {
k=1;
if(j==0) { // default category item
a=new Array();
O("Pick Item --->",""
}
if(j==1) { // 1st category items
a=new Array();
O("Pick Item --->",""
O("Buttons","O("Clocks","O("Cookies","O("Forms","O("Games","O("Messages","O("Miscellaneous","O("Navigation","O("Page Details","O("Pass. Protec.","O("Scrolls","O("User Details","O("Table Of Contents","}
if(j==2) { // 2nd category items
a=new Array();
O("Pick Item --->",""
O("How Do I...?","O("Script Help","O("Script Requests","O("Intro to JavaScript","O("What's New?","}
if(j==3) { // 3rd category items
a=new Array();
O("Pick Item --->",""
O("JS Question?","O("JS Contribution","O("Site Comments","O("Other ...","}
aln2=a.length;
getFormNum(formName);
if (formNum>=0) {
formNum = formNum + 1;
with (document.forms[formNum].elements[elementNum]) {
for (var i=options.length-1;i>0;i--) options=null;
for (var i=1;i<aln2;i++) options[i-1]=a;
options[0].selected=true;
}
}
} else {
jmp(formName,elementNum);
}
}
// End -->
</SCRIPT>
</head>
<!-- STEP TWO: Put this code into the BODY of your HTML document -->
<BODY>
<center>
<table border=0>
<tr valign=top>
<TD align=center><form name=f1 method=post action="" onSubmit="return false;">
<select name=m1 onChange="relate(this.form,0,this.selectedIndex); document.f2.m2.focus();">
<option value="/">Pick Category --->
<option value="/">JavaScripts
<option value="/">Message Forum
<option value="/">Feedback Form
</select></form></td>
<td align=center> <b>then</b> </td>
<td><form name=f2 method=post action="" onsubmit="return false;">
<select name="m2" onchange="jmp(this.form,0)">
<option value="/">Pick Item --->
<!--
Put a blank item (like below) for the MAXIMUM
number of items in one of your categories.
i.e. If your "largest" menu contains 5 items,
include 5 blank lines here. For 10, include
10, and so on.
-->
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
<option value="/">
</select></form></td>
</tr>
</table>
</center>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href=" JavaScript Source</a></font>
</center><p>
<!-- Script Size: 4.56 KB -->