Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Same problem different scenario for js script call

Status
Not open for further replies.

neiljabba

IS-IT--Management
May 22, 2003
86
GB
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=&quot;JavaScript&quot;>
<!--
v=false;
//-->
</SCRIPT>

<SCRIPT LANGUAGE=&quot;JavaScript1.1&quot;>
<!--
if (typeof(Option)+&quot;&quot; != &quot;undefined&quot;) v=true;
//-->
</SCRIPT>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

<!-- 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(&quot;Pick Item --->&quot;,&quot;&quot;);
}

if(j==1) { // 1st category items
a=new Array();
O(&quot;Pick Item --->&quot;,&quot;&quot;);
O(&quot;Buttons&quot;,&quot;O(&quot;Clocks&quot;,&quot;O(&quot;Cookies&quot;,&quot;O(&quot;Forms&quot;,&quot;O(&quot;Games&quot;,&quot;O(&quot;Messages&quot;,&quot;O(&quot;Miscellaneous&quot;,&quot;O(&quot;Navigation&quot;,&quot;O(&quot;Page Details&quot;,&quot;O(&quot;Pass. Protec.&quot;,&quot;O(&quot;Scrolls&quot;,&quot;O(&quot;User Details&quot;,&quot;O(&quot;Table Of Contents&quot;,&quot;}

if(j==2) { // 2nd category items
a=new Array();
O(&quot;Pick Item --->&quot;,&quot;&quot;);
O(&quot;How Do I...?&quot;,&quot;O(&quot;Script Help&quot;,&quot;O(&quot;Script Requests&quot;,&quot;O(&quot;Intro to JavaScript&quot;,&quot;O(&quot;What's New?&quot;,&quot;}

if(j==3) { // 3rd category items
a=new Array();
O(&quot;Pick Item --->&quot;,&quot;&quot;);
O(&quot;JS Question?&quot;,&quot;O(&quot;JS Contribution&quot;,&quot;O(&quot;Site Comments&quot;,&quot;O(&quot;Other ...&quot;,&quot;}

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=&quot;&quot; onSubmit=&quot;return false;&quot;>
<select name=m1 onChange=&quot;relate(this.form,0,this.selectedIndex); document.f2.m2.focus();&quot;>
<option value=&quot;/&quot;>Pick Category --->
<option value=&quot;/&quot;>JavaScripts
<option value=&quot;/&quot;>Message Forum
<option value=&quot;/&quot;>Feedback Form
</select></form></td>

<td align=center> <b>then</b> </td>

<td><form name=f2 method=post action=&quot;&quot; onsubmit=&quot;return false;&quot;>
<select name=&quot;m2&quot; onchange=&quot;jmp(this.form,0)&quot;>
<option value=&quot;/&quot;>Pick Item --->

<!--

Put a blank item (like below) for the MAXIMUM
number of items in one of your categories.
i.e. If your &quot;largest&quot; menu contains 5 items,
include 5 blank lines here. For 10, include
10, and so on.

-->

<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>

</select></form></td>

</tr>
</table>
</center>

<p><center>
<font face=&quot;arial, helvetica&quot; size=&quot;-2&quot;>Free JavaScripts provided<br>
by <a href=&quot; JavaScript Source</a></font>
</center><p>

<!-- Script Size: 4.56 KB -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top