populating a listbox from another listbox dynamically??

Reply

Join Date: Aug 2005
Posts: 52
Reputation: spidey is an unknown quantity at this point 
Solved Threads: 0
spidey's Avatar
spidey spidey is offline Offline
Junior Poster in Training

populating a listbox from another listbox dynamically??

 
0
  #1
Jan 31st, 2006
hello,

i have two dropdown listboxes: one is for the countries, the other one's for the areas. in the 'countries' listbox, the user can select multiple values. what he selects, the second listbox is going to display the country's/-tries' corresponding areas. all entries should be fetched from the database.

ex. if the user selects u.k. and philippines from the countries listbox, the areas listbox will automatically display all areas from these two countries, i.e. take note, taken from the database. btw, i think it'll need javascript too. :eek:

i hope you got what i mean and could help me, once again :o , with this problem. i really need it very badly and ASAP. :cry:

thank u in advance! happy new year!!
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 1
Reputation: iwahdan is an unknown quantity at this point 
Solved Threads: 0
iwahdan iwahdan is offline Offline
Newbie Poster

Re: populating a listbox from another listbox dynamically??

 
0
  #2
Feb 5th, 2006
<html dir="rtl">
<head>
<script language="javascript">

function section_onchange()
{
DEPARTMENTS = document.form1.DEPARTMENTS.options[document.form1.DEPARTMENTS.selectedIndex].value;
window.location.href = "list.asp?DEPT_ID=" + DEPARTMENTS
}

</script>
</head>
<%
DEPT_ID= request("DEPT_ID")

%>
<form method="POST" name=form1>

<table dir=ltr>
<tr>
<td bgcolor="#E7EFF7" width="29%" class="bodytxt">
Depts</td>
<td bgcolor="#E7EFF7" width="69%" class="bodytxt">


<%'------------------------------------ This select to select DEPARTMENTS -------------------------------%><select size="4" name="DEPARTMENTS" class=bord3333 dir="rtl" onchange="return section_onchange();" multiple>
<option>-------------- CHOOSE DEPT----------------</option>
<%
Set Conn = server.createobject("adodb.connection")
Conn.open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=diwan;Data Source=10.35.12.20"
set rs1 = server.createobject("adodb.recordset")
sql = "select * from departments"
rs1.open sql,conn
if not rs1.eof then
while not rs1.eof
%>
<option value="<%=rs1("DEPT_ID")%>" <% if trim(DEPT_ID)= trim(rs1("DEPT_ID")) then %> selected <%end if%> >
<%=rs1("DEPT_NAME")%> </option>
<%
rs1.movenext
wend
rs1.close
set rs1 = nothing

' RESPONSE.WRITE SQL
'response.end
end if
%>

</select>






</td>
</tr>


<%'------------------------------------ This select to select city by DEPARTMENTS Id -------------------------------%>
<% if DEPT_ID <> "" then%>
<tr>
<td bgcolor="#E7EFF7" width="29%" class="bodytxt">
Subjects</td>
<td bgcolor="#E7EFF7" width="69%" class="bodytxt">




<select size="1" name="city" dir="rtl" class=bord3333>

<%
Set Conn = server.createobject("adodb.connection")
Conn.open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=diwan;Data Source=10.35.12.20"
set rs = server.createobject("adodb.recordset")
sql = "select * from SUBJECT where DEPT_ID= " & DEPT_ID
'reponse.write sql
rs.open sql,conn
if not rs.eof then
while not rs.eof
%>
<option value="<%=rs("subject_id")%>" <% if trim(subject_desc)= trim(rs("subject_desc")) then %> selected <%end if%> >
<%=rs("subject_desc")%> </option>
<%
rs.movenext
wend
rs.close
set rs = nothing
end if
%>
</select>

<%end if%><%'------------------------------------------------- End City select -----------------------------------------------------%>
</td>
</tr>
</table>
</form>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for ASP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC