Hi,
I'm new in JavaScript programming, i'm stuck at this dynamic combo box.
I'm having a table with:
1. company
2. category
3. subcategory
4. app_cd
5. app_name
What I want is,
1. when I select company(1st combo), all the category for the company is pulled in 2nd combo.
And when I select category (2nd combo), all the subcategory for the company and category is pulled in 3rd combo.
And when I select subcategory (3rd combo), all the app_cd for the company, category and subcategory is pulled in 4th combo. Until the last one
I managed to do until the 3rd combo box pull value based on 1st & 2nd combo box value, But i did not managed to pull the 4th & 5th combo based on 1st, 2nd & 3rd combo value.
My 4th & 5th combo is blank.
I would appreciate if someone can help me with this. Thanks.
below is my code:
Thanks & Regards,
Ummul
I'm new in JavaScript programming, i'm stuck at this dynamic combo box.
I'm having a table with:
1. company
2. category
3. subcategory
4. app_cd
5. app_name
What I want is,
1. when I select company(1st combo), all the category for the company is pulled in 2nd combo.
And when I select category (2nd combo), all the subcategory for the company and category is pulled in 3rd combo.
And when I select subcategory (3rd combo), all the app_cd for the company, category and subcategory is pulled in 4th combo. Until the last one
I managed to do until the 3rd combo box pull value based on 1st & 2nd combo box value, But i did not managed to pull the 4th & 5th combo based on 1st, 2nd & 3rd combo value.
My 4th & 5th combo is blank.
I would appreciate if someone can help me with this. Thanks.
below is my code:
Code:
<form method="get" action="budget_add.asp" onSubmit="return checkSubmit(this);" id=form1 name=form1>
<table>
<tr>
<td class="helpdeskText1" width=10%>Budget for Year:</td>
<td class="helpdeskText1" width=40%>
<select name=b_year>
<option value="FY06" selected>FY06</option>
<option value="FY05">FY05</option>
</select>
</td>
<td class="helpdeskText1" width=10%> </td>
<td class="helpdeskText1" width=40%> </td>
</tr>
<tr>
<td class="helpdeskText1" width="10%">Budget Company:</td>
<td width="40%">
<%CompSQL = "SELECT distinct comp_cd FROM eBudget_approved"
SET rsComp = objConn.Execute(CompSQL)%>
<select class="helpdeskText3" name="b_comp" onchange="changeCat(this.options[this.selectedIndex].value, b_cat);">
<option value="[Please Select]" selected>[Please Select]</option>
<%DO UNTIL rsComp.EOF%>
<option value="<%=rsComp("comp_cd")%>"><%=rsComp("comp_cd")%></option>
<%rsComp.MoveNext()
LOOP%>
</select>
<script>
function changeCat(Comp1, Cat1) {
while (Cat1.options.length > 0) {
Cat1.options[0] = null;
}
Cat1.options[0] = new Option("[Please Select]", "[Please Select]", true);
<%rsComp.MoveFirst()%>
<%do until rsComp.EOF%>
if (Comp1 == "<%=rsComp("comp_cd")%>") {
<%
CatSQL = "SELECT distinct cat_cd, comp_cd FROM eBudget_approved " & _
"where comp_cd = '" & rsComp("comp_cd") & "'"
SET rsCat = objConn.Execute(CatSQL)
CompCount = 1%>
<%DO UNTIL rsCat.EOF%>
Cat1.options[<%=CompCount%>] = new Option("<%=rsCat("cat_cd")%>", "<%=rsCat("cat_cd")%>");
<% CompCount = CompCount + 1
rsCat.MoveNext()
LOOP%>
}
<%rsComp.MoveNext()
LOOP%>
}
</script>
</td>
<td class="helpdeskText1" width="10%">Budget Category:</td>
<td width="40%">
<select class="helpdeskText3" name="b_cat" onchange="changeSubCat(this.options[this.selectedIndex].value, b_subcat);">
</select>
<script>
function changeSubCat(Cat12, SubCat1) {
while (SubCat1.options.length > 0) {
SubCat1.options[0] = null;
}
SubCat1.options[0] = new Option("[Please Select]", "[Please Select]", true);
<%rsCat.MoveFirst()%>
<%do until rsCat.EOF%>
if (Cat12 == "<%=rsCat("cat_cd")%>") {
<%
SubCatSQL = "SELECT distinct subcat_cd, comp_cd, cat_cd FROM eBudget_approved " & _
"where comp_cd = '" & rsCat("comp_cd") & "' and cat_cd = '" & rsCat("cat_cd") & "'"
SET rsSubCat = objConn.Execute(SubCatSQL)
CatCount = 1%>
<%DO UNTIL rsSubCat.EOF%>
SubCat1.options[<%=CatCount%>] = new Option("<%=rsSubCat("subcat_cd")%>", "<%=rsSubCat("subcat_cd")%>");
<% CatCount = CatCount + 1
rsSubCat.MoveNext()
LOOP%>
}
<%rsCat.MoveNext()
LOOP%>
}
</script>
</td>
</tr>
<tr>
<td class="helpdeskText1" width="10%">Budget SubCategory:</td>
<td width="40%">
<select class="helpdeskText3" name="b_subcat" onchange="changeAppcd(this.options[this.selectedIndex].value, b_app);">
</select>
<script>
function changeAppcd(Subcat, App1) {
while (App1.options.length > 0) {
App1.options[0] = null;
}
App1.options[0] = new Option("[Please Select]", "[Please Select]", true);
<%rsSubCat.MoveFirst()%>
<%do until rsSubCat.EOF%>
if (Subcat == "<%=rsSubCat("subcat_cd")%>") {
<%
AppSQL = "SELECT distinct app_cd, cat_cd, comp_cd, subcat_cd FROM eBudget_approved " & _
"where comp_cd = '" & rsSubCat("comp_cd") & "' and cat_cd = '" & rsSubCat("cat_cd") & "' and subcat_cd = '" & rsSubCat("subcat_cd") & "'"
SET rsApp = objConn.Execute(AppSQL)
AppCount = 1%>
<%DO UNTIL rsApp.EOF%>
App1.options[<%=AppCount%>] = new Option("<%=rsApp("app_cd")%>", "<%=rsApp("app_cd")%>");
<% AppCount = AppCount + 1
rsApp.MoveNext()
LOOP%>
}
<%rsSubCat.MoveNext()
LOOP%>
}
</script>
</td>
<td class="helpdeskText1" width="10%"> </td>
<td width="40%"></td>
</tr>
<tr>
<td class="helpdeskText1" width="10%">Budget Application:</td>
<td width="40%">
<select class="helpdeskText3" name="b_app" onchange="changeApp(this.options[this.selectedIndex].value, b_app_name);">
</select>
<script>
function changeApp(Appn, Appn1) {
while (Appn1.options.length > 0) {
Appn1.options[0] = null;
}
appd1.options[0] = new Option("[Please Select]", "[Please Select]", true);
<%rsApp.MoveFirst()%>
<%do until rsApp.EOF%>
if (Appn == "<%=rsApp("app_cd")%>") {
<%
AppdSQL = "SELECT distinct app_name, comp_cd, cat_cd, subcat_cd, app_cd FROM eBudget_approved " & _
"where comp_cd = '" & rsApp("comp_cd") & "' and cat_cd = '" & rsApp("cat_cd") & "' and subcat_cd = '" & rsApp("subcat_cd") & "' and app_cd = '" & rsApp("app_cd") & "'"
SET rsAppd = objConn.Execute(AppdSQL)
AppdCount = 1%>
<%DO UNTIL rsAppd.EOF%>
Appn1.options[<%=AppCount%>] = new Option("<%=rsAppd("app_name")%>", "<%=rsAppd("app_name")%>");
<% AppdCount = AppdCount + 1
rsAppd.MoveNext()
LOOP%>
}
<%rsApp.MoveNext()
LOOP%>
}
</script>
</td>
<td class="helpdeskText1" width="10%">Application Detail:</td>
<td width="40%"><select class="helpdeskText3" name="b_app_name"></select></td>
</tr>
<tr>
<td class="helpdeskText1" width="10%"> </td>
<td width="40%"> </td>
<td class="helpdeskText1" width="10%"><input name="submit" type="submit" value="Show"></td>
<td width="40%"></td>
</tr>
</table>
</form>
Thanks & Regards,
Ummul