...

View Full Version : another dropdown box



needhelp26
07-06-2004, 03:14 AM
Hi,

I came across this code , I would like to know how to implement two more boxes to the script. When you help, please comment, so that I can understand how to add.



<html>
<head>

<title>New Tutorial</title>

<script language=javascript>
<!-- hide from old browsers...
/* dynamic select menus -- written by Matt Reinfeldt
feel free to use, modify, copy, distribute, and otherwise abuse this code!
if you find any problems, let me know, and I will try to find a fix for it.
*/


// assign var info to new array. List menu1 and menu2 with * and |. * lists menu1 and | lists menu2
var info = new Array(
"Robert Jordan*The Wheel of Time|The Great Hunt",
"R.A. Salvatore*The Crystal Shard|Streams of Silver|Homeland|Exile|Sojourn",
"Raymond E. Feist*Magician: Apprentice|Magician: Master|Silverthorn|A Darkness At Sethanon",
"David Eddings*Pawn of Prophesy|Queen of Sorcery|Magician's Gambit|Castle of Wizardry|Enchanters' End Game"
);

/**************************************************************************************************** **/
//function to split the menu1 and menu2
function stringSplit ( string, delimiter ) {
if ( string == null || string == "" ) {
return null;
} else if ( string.split != null ) {
return string.split ( delimiter );
} else {
var ar = new Array();
var i = 0;
var start = 0;
while( start >= 0 && start < string.length ) {
var end = string.indexOf ( delimiter, start ) ;
if( end >= 0 ) {
ar[i++] = string.substring ( start, end );
start = end+1;
} else {
ar[i++] = string.substring ( start, string.length );
start = -1;
}
}
return ar;
}
}
/**************************************************************************************************** **/
//assign menu1 and menu2 to new array
var menu1 = new Array();
var menu2 = new Array();
/**************************************************************************************************** **/
//function to createmenus
function createMenus () {
//assign i as 0, if i is greater than info(new array)length then i++
for ( var i=0; i < info.length; i++ ) {
//assign stringSplit to menu1 with *
menu1[i] = stringSplit ( info[i], '*' );
//assign stringSplit to menu2 with |
menu2[i] = stringSplit ( menu1[i][1], '|' );
}
//kind of understand the below part
var author = document.myForm.main;
var book = document.myForm.title;

author.length = menu1.length;
book.length = menu2[0].length;
for ( var i=0; i < menu1.length; i++ ) {
author.options[i].value = menu1[i][0];
author.options[i].text = menu1[i][0];
}
document.myForm.main.selected = 0;
for (var x=0; x < menu2[0].length; x++) {
book.options[x].text = menu2[0][x];
book.options[x].value = menu2[0][x];
}
document.myForm.title.selected = 0;
}

/**************************************************************************************************** **/
//function to updatemenus
function updateMenus ( what ) {
var sel = what.selectedIndex;

if ( sel >= 0 && sel < menu1.length )
var temp = menu2[sel];
else
var temp = new Array ();

what.form.title.length = temp.length;

for ( var i = 0; i < temp.length; i++ ) {
what.form.title.options[i].text = temp[i];
what.form.title.options[i].value = temp[i];
}
what.form.title.selected=0;
}
// end of hiding -->
</script>
</head>
<!--onLoad ="createmenus() function-->
<body background="" bgcolor="#ffffff" text="#400040" link="#ff0080" vlink="#ff8080" alink="#ff0000" onLoad="createMenus()">
<center><h1>New Select Menu Tutorial</h1></center>

<form name=myForm><p>
Author's name: &nbsp
<!-- variable name "main" is assigned to Select name. Onchange = updateMenus(this)function-->
<select name="main" size=1 onChange="updateMenus(this)">
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<option>
<option>
</select>
<p>
Titles:&nbsp
<!-- variable name "title" is assigned to select name-->
<select name="title" size=1>
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<option>
<option>
</select>
</form>
</body>
</html>



I was trying to add new arrray3 and 4 and tried to do some changes within the code, but no luck.

Roy, you are right. I am sorry.

Roy Sinclair
07-07-2004, 08:55 PM
As a general principle, we don't work on scripts taken form other sources when the credits to the authors have been stripped out. Edit your original message to restore the credits and then we'll have a go at it.

It may seem nitpicky but the author does deserve credit for their work (or blame :eek: ).

lordofthesword8
07-08-2004, 12:16 PM
As a general principle, we don't work on scripts taken form other sources when the credits to the authors have been stripped out. Edit your original message to restore the credits and then we'll have a go at it.

It may seem nitpicky but the author does deserve credit for their work (or blame :eek: ).

If you read the third line of the script, it says "written by Matt Reinfeldt". Isnt that credit?

Ill have a go at the script, but why dont you just contact the author like it says in the script?

LOTS8

needhelp26
07-08-2004, 02:48 PM
If you read the third line of the script, it says "written by Matt Reinfeldt". Isnt that credit?

Ill have a go at the script, but why dont you just contact the author like it says in the script?

LOTS8

Yes, that is wise thinking but the sad part I don't have any other details of the author. If someone knows, your info is welcomed. Meanwhile, if someone can help or at least give me instructions to modify, I greatly appreciate your help. I am kinda stuck with the Functions and that is where I don't know.Thank you so much for all trouble taken.

Vincent Puglia
07-08-2004, 04:07 PM
umpteen links; one of them has to be the original page
http://www.alexa.com/search?amzn_id=alexa65-tb-20&q=Matt+Reinfeldt&p=TBChrome

Vinny



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum