By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,974 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,974 IT Pros & Developers. It's quick & easy.

Multiple select drop down poplulating sub drop down

P: n/a
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 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
sc***@dettcom.com 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 '06 #2

P: n/a
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("AL L" <cfloop
query="get_sub_group","#sub_group_title#"</cfloop>);
</cfloop>

makeModel.forValue("POLICE").addOptions("SWAT","DE TECTIVE","DISPATCH");
// Add options if VALUE of option is selected
makeModel.forText("FIRE").addOptions("COMMAND","CH IEF","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:
sc***@dettcom.com 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 '06 #3

P: n/a
Actually I just got it. Of course minutes after posting my previous
message.

It was using the following (addOptionsTextValue):

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

Thank you for all your help!!!

sc***@dettcom.com 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("AL L" <cfloop
query="get_sub_group","#sub_group_title#"</cfloop>);
</cfloop>

makeModel.forValue("POLICE").addOptions("SWAT","DE TECTIVE","DISPATCH");
// Add options if VALUE of option is selected
makeModel.forText("FIRE").addOptions("COMMAND","CH IEF","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:
sc***@dettcom.com 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 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.