Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    another dropdown box

    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.

    Code:
    <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.
    Last edited by needhelp26; 07-08-2004 at 01:12 AM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ).
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New Coder
    Join Date
    Jun 2004
    Location
    Coventry, UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb What?

    Quote Originally Posted by Roy Sinclair
    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 ).
    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

  • #4
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by lordofthesword8
    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.

  • #5
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    umpteen links; one of them has to be the original page
    http://www.alexa.com/search?amzn_id=...ldt&p=TBChrome

    Vinny
    Where the world once stood
    the blades of grass
    cut me still


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •