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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image/text slideshow w/ dhtml & categorical dropdown menus

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
What a mouthful! I am trying to create a script whereby I can show off my collection of badges using a slideshow type format.

The first dropdown menu you choose the category, which then selects the contents of the second menu where you choose the badge to look at. When you choose the badge, both the image and the text description 'should' change.

This is my first real attempt at javascript. I've 'stolen' bits from free databases and tried to alter it. But now I'm stuck trying to marry the dhtml text bit to the rest of it. Can anyone offer any advice?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<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;>
<!-- 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) document.base.src=options.value;
}
}
}
function O(txt,jpg) {
a[k]=new Option(txt,jpg);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;UK Fanclub 1987&quot;,&quot;clubuk87.jpg&quot;);
O(&quot;UK Fanclub 1988&quot;,&quot;clubuk88.jpg&quot;);
O(&quot;Cookies&quot;);
O(&quot;Forms&quot;);
O(&quot;Games&quot;);
}

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

if(j==3) { // 3rd category items
a=new Array();
O(&quot;Pick Item --->&quot;,&quot;&quot;);
O(&quot;JS Question?&quot;);
O(&quot;JS Contribution&quot;);
O(&quot;Site Comments&quot;);
O(&quot;Other ...&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>
<body bgcolor=#ffffff text=#000000 link=#0000FF alink=#0000FF vlink=#0444C6 topmargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0 onload=&quot;window.defaultStatus='MLP Pins and Badges';return true;fanclub.display_text()&quot;>

<p><br><br><br>
<center>
<table border=0 cellpadding=0 cellspacing=0 width=395><tr><td width=160>
<img src=&quot;clubuk87.jpg&quot; width=&quot;150&quot; height=&quot;150&quot; border=&quot;1&quot; name=&quot;base&quot; alt=&quot;Pin&quot;></td><td>

<form name=f1>
<select name=m1 onChange=&quot;relate(this.form,0,this.selectedIndex); document.Myform.PIN.focus();&quot;>
<option value=&quot;/&quot;>Pick Category --->
<option value=&quot;/&quot;>Fan Clubs
<option value=&quot;/&quot;>Promotional
<option value=&quot;/&quot;>Greetings Cards
<option value=&quot;/&quot;>Free with Comic
<option value=&quot;/&quot;>Unofficial
</select></form>
<b>then</b>
<form name=Myform onChange=&quot;change()&quot;>
<select name=&quot;PIN&quot; onchange=&quot;jmp(this.form,0)&quot;>
<option value=&quot;/&quot;>Pick Item --->
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
<option value=&quot;/&quot;>
</select></form>

</td></tr><tr><td colspan=2><br>

<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
red= new Array();
red[0]=&quot;A concentrically arranged rainbow around the edge (from edge inwards: pink, yellow, blue, lilac). Majesty stands in the centre. The 'My Little Pony' logo, in the early type font, is over the rainbow at the top. The words '1987 Club Member' are written over the rainbow at the bottom.<p>Origins: Issued with UK Fan Club<br>Diameter: 5cm approx.<br>Fastener: Brooch pin.&quot;;
red[1]=&quot;This is the same design as the 1987 club badge, except for three minor differences; <br>\n1. Obviously, the badge is marked '1988'\n2. The words 'Club Member' are emboldened.\n3. The MLP logo is in the later type font.\n\nOrigins: Issued with UK Fan Club\nDiameter: 5cm approx.\nFastener: Brooch pin.&quot;;

dom = (document.getElementById)? true:false
ns4 = (document.layers)? true:false
ie4 = (document.all && !dom)? true:false
if (ns4) document.write('<textarea name=&quot;dropdownchanger&quot; wrap=&quot;soft&quot; rows=&quot;11&quot; cols=&quot;49&quot; STYLE=&quot;overflow: hidden;&quot;>' +red[0] + '</textarea><br>')
else document.write('<div id=&quot;dropdownchanger&quot; style=&quot;width:400px; height:50px;&quot;><p>' +red[0] + '</p></div>')
function change(){
if (ns4) {document.Myform.dropdownchanger.value=red[document.Myform.PIN.options.selectedIndex]}
if (ie4) {document.all['dropdownchanger'].innerHTML ='<p>' + red[document.Myform.PIN.options.selectedIndex] + '</p>'}
else if (dom) {document.getElementById(&quot;dropdownchanger&quot;).innerHTML ='<p>' + red[document.Myform.PIN.options.selectedIndex] + '</p>'}
}
</script>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top