如何根据我在另一个下拉列表中所做的选择填充下拉列表?
How to populate a dropdown list based on the choice i've made in another dropdown list?
我可以根据我在另一个下拉列表中选择的值填充一个下拉列表吗?
例如:我有 2 个下拉列表。第一个包含 OptionA 和 OptionB。如果我选择 OptionA,则第二个下拉列表将填充值 1、值 2、值 3。如果我在第一个下拉列表中选择 OptionB,那么第二个下拉列表将填充状态 1、状态 2、状态 3。
我该怎么做?谢谢!
此代码在我的 ddlb_division 对象的 "SelectionChanged" 事件中。我有 2 个 DDLB,ddlb_division & ddlb_section.
int li_division_id
int li_section_id
string ls_section
SetPointer(HourGlass!)
//Clears the DDLBs
ddlb_section.Reset()
//Gets the Division ID
li_division_id = integer(Left(this.Text(index), 2))
//Cursor to gather the Sections under the selected Division
declare section cursor for
select section_id, section_name
from tadtp_sections
where division_id = :li_division_id;
//Open cursor
open section;
//Get first row of data
fetch section into :li_section_id, :ls_section;
//Loop while we have rows
do while(SQLCA.SQLCode = 0)
//Adds item to DDLB
ddlb_section.AddItem(string(li_section_id, "00") + " " + Trim(ls_section))
//Gets next row
fetch section into :li_section_id, :ls_section;
loop
//Close cursor
close section;
//Enables controls
ddlb_section.Enabled = true
我可以根据我在另一个下拉列表中选择的值填充一个下拉列表吗? 例如:我有 2 个下拉列表。第一个包含 OptionA 和 OptionB。如果我选择 OptionA,则第二个下拉列表将填充值 1、值 2、值 3。如果我在第一个下拉列表中选择 OptionB,那么第二个下拉列表将填充状态 1、状态 2、状态 3。
我该怎么做?谢谢!
此代码在我的 ddlb_division 对象的 "SelectionChanged" 事件中。我有 2 个 DDLB,ddlb_division & ddlb_section.
int li_division_id
int li_section_id
string ls_section
SetPointer(HourGlass!)
//Clears the DDLBs
ddlb_section.Reset()
//Gets the Division ID
li_division_id = integer(Left(this.Text(index), 2))
//Cursor to gather the Sections under the selected Division
declare section cursor for
select section_id, section_name
from tadtp_sections
where division_id = :li_division_id;
//Open cursor
open section;
//Get first row of data
fetch section into :li_section_id, :ls_section;
//Loop while we have rows
do while(SQLCA.SQLCode = 0)
//Adds item to DDLB
ddlb_section.AddItem(string(li_section_id, "00") + " " + Trim(ls_section))
//Gets next row
fetch section into :li_section_id, :ls_section;
loop
//Close cursor
close section;
//Enables controls
ddlb_section.Enabled = true