Forum Moderators: open

Message Too Old, No Replies

newbiehelp

multiple dynamic dropdown

         

newbiehelp

3:27 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



I would like to know where I can find multiple dynamic dropdown in javascript. Is there any good sites where I can take as a free tutorial? I need four dropdowns, based on each other, ie., when clicke on first dropdown and choose a topic, based on first topic, should get another dropdown, when click on second, based on second, should get the third and the fourth should be based on third and should be a textbox. Is there a way to do this, and can I find any good sites which explains these types of dropdowns? Thanks.

kodaks

6:18 pm on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may want to try:
javascriptkit
or
dynamicdrive

Best of luck!

tedster

3:04 am on Jul 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out this tutorial from our own BlobFisk:

[webmasterworld.com...]

It's much "leaner and meaner" than most of what you find on the web, very solid cross-browser support and with a nice tutorial, too.

fmaz

4:18 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



What you need to know is, if you don't want all your page to be reloaded between each drop down selection (to load new content on the next boxe), you need to pre-laod all possibles values.

Go see the nvidia or ATI download page, it quite the same thing as you seem to want, except that it is list instead of drop box.

++

newbiehelp

8:19 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



Thanks all for your suggestion. I found this code in one of the free codes sites, can someone please help with adding additional two more boxes to the coding. I tried with no luck.

<html>
<head>

<title>New Tutorial</title>

<script language=javascript>
<!-- hide from old browsers...

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 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;
}
}
/************************************************** ************************************************** **/

var menu1 = new Array();
var menu2 = new Array();
/************************************************** ************************************************** **/

function createMenus () {
for ( var i=0; i < info.length; i++ ) {

menu1[i] = stringSplit ( info[i], '*' );

menu2[i] = stringSplit ( menu1[i][1], '¦' );
}

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 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>
<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

<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

<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>

newbiehelp

2:01 am on Jul 7, 2004 (gmt 0)

10+ Year Member



Can someone please help me with this to add two more drop down boxes? Thanks.

fmaz

2:01 pm on Jul 7, 2004 (gmt 0)

10+ Year Member



Why the whole script is under <!-- --> (comments)?

newbiehelp

11:01 pm on Jul 7, 2004 (gmt 0)

10+ Year Member



That is not a comment in Javascript.

// for single line
/* for multiple lines*/

Am I right? If you see any of these comments within my code, please let me.