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 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    triple combo box

    Here is a script from Javascriptkit example:

    group[0][0]=new Option("---Select2---"," ");

    group[1][0]=new Option("Now Select This One"," ");
    group[1][1]=new Option("JavaScript","47");
    group[1][2]=new Option("DHTML","46");
    group[1][3]=new Option("CGI","45");

    what does the "47" "46" and "45" do?

    If I want to add another 3rd group:

    group[0][0]=new Option("---Select3---"," ");

    group[1][0]=new Option("Now Select This One"," ");
    group[1][1]=new Option("JavaScriptkit","47");' what no will I give here?
    group[1][2]=new Option("DHTMLsamples","46");
    group[1][3]=new Option("CGIexamples","45");

    please someone explain this example. Thanks.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    That number which is the 2nd parameter of the Option object will go to the value attribute of the <option> tag:

    <select>
    <option value="47">Javascript</option>
    </select>

    The value attribute (of the selected option) is the one submitted to the server. The text attribute (in between option tag) is what the user sees. If the value attribute is not specified, the text attribute will be the one submitted to the server.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankyou.

  • #4
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have another question pertaining to this code. I want to use the script as Include file within the html page. I want to insert because I do have a huge new option for each drop down box, and it is taking long time to load the page.

    1. By inserting the include file(script), will it reduce the time of loading?
    2. where should I include the .js file? I have showed a sample in red.

    <html>
    <head>
    <title>ComboBox[4]</title>
    <script src="include.js" type="text/javascript"></script>
    </head>
    <body>

    <FORM name="CBN">
    <table border="0" cellspacing="0" cellpadding="0">
    <tr align="center">
    <td nowrap height="11"> &nbsp;

    <select name="CBN1" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
    onChange="ReDirect1(this.options.selectedIndex)">
    <option selected>---Select1-------------</option>
    <option>1</option>
    <option>2</option>
    </select>
    <select name="CBN2" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
    onChange="ReDirect2(this.options.selectedIndex)">
    <option value=" " selected> </option>
    <option value=" " selected>---Select2--------------</option>
    <option value=" " selected>---Select2--------------</option>
    </select>
    <select name="CBN3" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
    onChange="ReDirect3(this.options.selectedIndex)">
    <option value=" " selected> </option>
    <option value=" " selected>---Select3----------------</option>
    <option value=" " selected>---Select3----------------</option>
    </select>
    <select name="CBN4" size="1" style="font-family: Lucida Console,Verdana, Tahoma, Arial; font-size: 9"
    onChange="ReDirect(this.options.selectedIndex)">
    <option value=" " selected> </option>
    <option value=" " selected>---Select4----------------</option>
    <option value=" " selected>---Select4----------------</option>
    </select>
    </body>
    </html>

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    The Triple Combo script by Javascriptkit should be inserted AFTER the <select> elements.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New Coder
    Join Date
    Jul 2005
    Location
    TX
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In the same script, in the third combo box if you click on an option it loads a new page, and the "value" tells what url to load.

    Code:
    secondGroup[2][2][0]=new Option("Now Select A Page"," ");
    secondGroup[2][2][1]=new Option("News.com","http://www.news.com");
    secondGroup[2][2][2]=new Option("Wired","http://www.wired.com");
    But how do I tell it to just stay at that option and not load any new pages? If I leave the value part blank it just reloads the page for some reason.

    URL of the script: http://www.javascriptkit.com/script/...plecombo.shtml


    EDIT: Nevermind. All you have to do is remove onChange from the third combo box declaration.
    Last edited by inko9nito; 12-15-2006 at 02:07 AM.
    Life is a game. The plot sucks but the graphics are awesome!

  • #7
    New Coder
    Join Date
    Dec 2008
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I have a fairly extensive implementation of the Triple Combo Box described in NeedHelp26's original message.

    I'm "very" new to js... Can someone explain once more (in very plain language) what the new Option values 47, 46 and 45 represent?

    group[1][0]=new Option("Now Select This One"," ");
    group[1][1]=new Option("JavaScript","47");
    group[1][2]=new Option("CSS","46");
    group[1][3]=new Option("Ajax","45");

    group[2][0]=new Option("Now Select This One"," ");
    group[2][1]=new Option("General News","115");
    group[2][2]=new Option("Technology News","116");

    Also, since I'm creating my own Triple Combo, can someone also explain how I can manually calculate the values for all (9) of my groups?

    Thanks!

  • #8
    New Coder
    Join Date
    Dec 2008
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts
    glenngv,

    With regards to the Cut and Paste Triple Combo and your explaination above, I understood the text "Javascript", "CSS" and "Ajax" are the text the user sees, and that "47", "46" and "45" are values sent back to the server.

    However, I'm still not getting the whole picture

    What do these values represent to the code and/or to the server? And why are the first series of numbers in reverse order?

    I can't just leave the values set to null. When I do, the code refuses to function properly. So the values must be used by the server for something...

    I have many additional menus to create.

    So I can create them, can you explain (in simple terms ) how do I go about calculating the correct values to input for each additional set of menus that I wish to add?

    If 47, 46 and 45 are the first series and 115, 116 and 117 are the second series, what is the third series?

    Thanks,
    Dale


    group[1][0]=new Option("Now Select This One"," ");
    group[1][1]=new Option("JavaScript","47");
    group[1][2]=new Option("CSS","46");
    group[1][3]=new Option("Ajax","45");

    group[2][0]=new Option("Now Select This One"," ");
    group[2][1]=new Option("General News","115");
    group[2][2]=new Option("Technology News","116");

  • #9
    New Coder
    Join Date
    Dec 2008
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Please disregard. I have it fugured out now...

    For anyone else that was wondering, all that matters is that these values be unique.

    For example, you cannot use the same value more than once.


    group[1][0]=new Option("Now Select This One"," ");
    group[1][1]=new Option("JavaScript","47");
    group[1][2]=new Option("CSS","46");
    group[1][3]=new Option("Ajax","45");

    group[2][0]=new Option("Now Select This One"," ");
    group[2][1]=new Option("General News","115");
    group[2][2]=new Option("Technology News","116");


  •  

    Posting Permissions

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