|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
dynamic populating list to combo
Hi
How to requery list box dynamically I have list boxes and combo box one of them needs to list values related to whatever is chosen in the first box. I'd like to populate the second box on the select event of the first one The first one will g I have tables one is subindicator, criteria_sql, and ref_model.ref_reg, so on when they select the subindicator to populate a combo the subindicator id will go and select cretiria_sql table and select the sql query is like (Select gstype as fld1 From ref_type Order by fld1 ) then need to excute this and spit data into combo box. Here is the script below I have When I select it is spit one data because I am not able to assign as to run query (nested cfoutput) <CFQUERY name="getSubIndicators" Datasource="#DSN#"> Select * From sub_indicator </CFQUERY> <CFLOOP index="k" From="1" to = "#getSubIndicators.recordcount#"> <CFQUERY name="getCriteria#getSubIndicators.sub_code[k]#" datasource="#DSN#"> SELECT * FROM criteria_sql where sub_code = #getSubIndicators.sub_code[k]# </CFQUERY> </CFLOOP> function updatesel4(form) { form.criteria.length = 1; form.criteria.selectedIndex = 0; choice = form.subIndicator.options[form.subIndicator.selectedIndex ].value; <CFLOOP Index="count" from="1" to="#getSubIndicators.recordcount#"> <CFOUTPUT> if (choice == "#getSubIndicators.sub_code[count]#") { <CFLOOP index="x" From="1" to="#Evaluate('getCriteria#getSubIndicators.sub_code[coun t]#.recordcount')#"> (form.criteria.length)++; <cfset t = "#Evaluate('getCriteria#getSubIndicators.sub_code[count]# .Sub_sql[x]')#"> <cfquery name="temp" datasource="#DSN#"> #t# </cfquery> form.criteria.options[form.criteria.length - 1].text = "#temp.fld1#" form.criteria.options[form.criteria.length - 1].value = "#temp.fld1#" </CFLOOP> } </CFOUTPUT> </CFLOOP> } <table> <tr> <td><br> <table height="18" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="Header" align="center" valign="middle"> Sub Indicator:</td> </tr> </table></td> <td><br> <select name="subIndicator" class="small" OnChange="updatesel4(this.form)" > <OPTION VALUE = "%"></OPTION> <CFLOOP index="y" From="1" to="6"> <OPTION VALUE = ""> </OPTION> </CFLOOP> </select></td> </tr> <tr> <td><br> <table height="18" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="Header" align="center" valign="middle"> Criteria Selection:</td> </tr> </table></td> <td class="small"><br> <select name="criteria" size="5" multiple class="small"> <option VALUE = "%"></option> <CFLOOP index="y" From="1" to="50"> <OPTION VALUE = ""> </OPTION> </CFLOOP> </select> <input type="submit" name="Submit2" value="< "> <input type="submit" name="Submit3" value="<<"> <input type="submit" name="Submit4" value=">>"> <input type="submit" name="Submit5" value="> "> <select name="criteriaSelect" size="1" multiple> </select> </td> </tr> |
|
#2
|
|||
|
|||
|
I don't know enough about Javascript to comment on your code, but you are sort of reinventing the wheel on this. There are some custom tags out there for free that will do this (cf_twoselectrelated and cf_threeselectrelated), and there is the QForms Javascript API that does this and a whole lot more. www.pengoworks.com. Hope that helps.
Brian |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > dynamic populating list to combo |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|