Multiple select drop down poplulating sub drop down

Discussion in 'Javascript' started by scott@dettcom.com, Nov 8, 2006.

  1. Guest

    Hello all,

    I am ripping my hair out over this and maybe someone could help.

    I have a site that has groups and subgroups of those groups that all
    have int id's.

    I am trying to have a multiple select drop down (could select more than
    one group) like the following:

    1 - group a
    2 - group b
    3 - group c
    4 - group d

    and if you would select group a (id value = 1) and group c (id value =
    3) the sub drop drop will populate (without having to reload) with the
    values of those groups' sub groups:

    1 - group a - subgroup 1
    1 - group a - subgroup 2
    1 - group a - subgroup 3
    1 - group a - subgroup 4
    3 - group c - subgroup 5
    3 - group c - subgroup 6
    3 - group c - subgroup 7
    3 - group c - subgroup 8

    Does this make sense???? Please help!!!!!
     
    , Nov 8, 2006
    #1
    1. Advertising

  2. Matt Kruse Guest

    Matt Kruse, Nov 9, 2006
    #2
    1. Advertising

  3. Guest

    Matt, thank you so much for the advice. It seems to be working quite
    nicely. However, I cannot get the values which are integers and the
    names for text.

    here is the code below.









    <script type="text/javascript">
    var makeModel = new DynamicOptionList("alert_group","SUBGROUP");
    makeModel.forValue("ALL PUBLIC").addOptions("NONE"); // Add options if
    VALUE of option is selected
    <cfloop query="get_group_type">
    <CFQUERY Name = "get_sub_group" Datasource = #application.dsn#>
    SELECT * FROM ACCOUNT_SUB_GROUPS
    WHERE account_id = '#session.account_id#' AND group_id =
    '#get_group_type.group_id#'
    </CFQUERY>

    makeModel.forValue("#group_title#").addOptions("ALL" <cfloop
    query="get_sub_group"> ,"#sub_group_title#"</cfloop>);
    </cfloop>

    makeModel.forValue("POLICE").addOptions("SWAT","DETECTIVE","DISPATCH");
    // Add options if VALUE of option is selected
    makeModel.forText("FIRE").addOptions("COMMAND","CHIEF","CHEM"); // Add
    these options if TEXT of option is selected




    </script>

    <TR>
    <TD align="right" height="30" valign="top"><FONT SIZE="0" FACE="MS
    Sans Serif"><B>Group (s):&nbsp;</B></FONT></TD>
    <TD COLSPAN=2><SELECT style="width:269px; font:Arial, Helvetica,
    sans-serif; font-size:12px" NAME="alert_group" multiple size="4"
    class="text">
    <cfif #parameterexists(session.group_id)# eq 'YES'>
    <cfif #groups.sendpublic# eq '1'>
    <OPTION VALUE="ALL PUBLIC"> ALL PUBLIC
    </cfif>
    <cfelse>
    <OPTION VALUE="ALL PUBLIC"> ALL PUBLIC
    </cfif>
    <cfloop query="get_group_type">
    <OPTION VALUE="#group_title#"> #group_title#
    </cfloop>


    </SELECT><br><font face="Arial, Helvetica, sans-serif"
    style="font-size:9px">* - Hold down Ctrl button for multiple
    selections.</font></TD>

    </TR>





    <TR>
    <TD align="right" height="30" valign="top"><FONT SIZE="0" FACE="MS
    Sans Serif"><B>Sub Group (s):&nbsp;</B></FONT></TD>
    <TD COLSPAN=2>
    <select style="width:269px; font:Arial, Helvetica, sans-serif;
    font-size:12px" name="SUBGROUP" multiple size=5>
    <script
    type="text/javascript">makeModel.printOptions("SUBGROUP")</script>
    </select><br><font face="Arial, Helvetica, sans-serif"
    style="font-size:9px">* - Hold down Ctrl button for multiple
    selections.</font>
    </td>

    </tr>











    Matt Kruse wrote:
    > wrote:
    > > I am trying to have a multiple select drop down (could select more
    > > than one group) like the following:
    > > ...
    > > and if you would select group a (id value = 1) and group c (id value =
    > > 3) the sub drop drop will populate (without having to reload) with the
    > > values of those groups' sub groups:

    >
    > If you don't want to re-invent the wheel, check out:
    > http://www.JavascriptToolbox.com/lib/dynamicoptionlist/
    >
    > --
    > Matt Kruse
    > http://www.JavascriptToolbox.com
    > http://www.AjaxToolbox.com
     
    , Nov 9, 2006
    #3
  4. Guest

    Actually I just got it. Of course minutes after posting my previous
    message.

    It was using the following (addOptionsTextValue):

    makeModel.forValue("#group_id#").addOptionsTextValue("ALL", "0" <cfloop
    query="get_sub_group"> ,"#sub_group_title#"
    ,"#sub_group_id#"</cfloop>);

    Thank you for all your help!!!

    wrote:
    > Matt, thank you so much for the advice. It seems to be working quite
    > nicely. However, I cannot get the values which are integers and the
    > names for text.
    >
    > here is the code below.
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > <script type="text/javascript">
    > var makeModel = new DynamicOptionList("alert_group","SUBGROUP");
    > makeModel.forValue("ALL PUBLIC").addOptions("NONE"); // Add options if
    > VALUE of option is selected
    > <cfloop query="get_group_type">
    > <CFQUERY Name = "get_sub_group" Datasource = #application.dsn#>
    > SELECT * FROM ACCOUNT_SUB_GROUPS
    > WHERE account_id = '#session.account_id#' AND group_id =
    > '#get_group_type.group_id#'
    > </CFQUERY>
    >
    > makeModel.forValue("#group_title#").addOptions("ALL" <cfloop
    > query="get_sub_group"> ,"#sub_group_title#"</cfloop>);
    > </cfloop>
    >
    > makeModel.forValue("POLICE").addOptions("SWAT","DETECTIVE","DISPATCH");
    > // Add options if VALUE of option is selected
    > makeModel.forText("FIRE").addOptions("COMMAND","CHIEF","CHEM"); // Add
    > these options if TEXT of option is selected
    >
    >
    >
    >
    > </script>
    >
    > <TR>
    > <TD align="right" height="30" valign="top"><FONT SIZE="0" FACE="MS
    > Sans Serif"><B>Group (s):&nbsp;</B></FONT></TD>
    > <TD COLSPAN=2><SELECT style="width:269px; font:Arial, Helvetica,
    > sans-serif; font-size:12px" NAME="alert_group" multiple size="4"
    > class="text">
    > <cfif #parameterexists(session.group_id)# eq 'YES'>
    > <cfif #groups.sendpublic# eq '1'>
    > <OPTION VALUE="ALL PUBLIC"> ALL PUBLIC
    > </cfif>
    > <cfelse>
    > <OPTION VALUE="ALL PUBLIC"> ALL PUBLIC
    > </cfif>
    > <cfloop query="get_group_type">
    > <OPTION VALUE="#group_title#"> #group_title#
    > </cfloop>
    >
    >
    > </SELECT><br><font face="Arial, Helvetica, sans-serif"
    > style="font-size:9px">* - Hold down Ctrl button for multiple
    > selections.</font></TD>
    >
    > </TR>
    >
    >
    >
    >
    >
    > <TR>
    > <TD align="right" height="30" valign="top"><FONT SIZE="0" FACE="MS
    > Sans Serif"><B>Sub Group (s):&nbsp;</B></FONT></TD>
    > <TD COLSPAN=2>
    > <select style="width:269px; font:Arial, Helvetica, sans-serif;
    > font-size:12px" name="SUBGROUP" multiple size=5>
    > <script
    > type="text/javascript">makeModel.printOptions("SUBGROUP")</script>
    > </select><br><font face="Arial, Helvetica, sans-serif"
    > style="font-size:9px">* - Hold down Ctrl button for multiple
    > selections.</font>
    > </td>
    >
    > </tr>
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > Matt Kruse wrote:
    > > wrote:
    > > > I am trying to have a multiple select drop down (could select more
    > > > than one group) like the following:
    > > > ...
    > > > and if you would select group a (id value = 1) and group c (id value =
    > > > 3) the sub drop drop will populate (without having to reload) with the
    > > > values of those groups' sub groups:

    > >
    > > If you don't want to re-invent the wheel, check out:
    > > http://www.JavascriptToolbox.com/lib/dynamicoptionlist/
    > >
    > > --
    > > Matt Kruse
    > > http://www.JavascriptToolbox.com
    > > http://www.AjaxToolbox.com
     
    , Nov 9, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    792
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,040
    weiwei
    Jan 5, 2007
  3. Ben
    Replies:
    2
    Views:
    910
  4. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,062
    Lawrence D'Oliveiro
    May 20, 2011
  5. palmiere
    Replies:
    1
    Views:
    417
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page