944,092 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 7642
  • ASP RSS
Jan 31st, 2006
0

populating a listbox from another listbox dynamically??

Expand Post »
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!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
spidey is offline Offline
53 posts
since Aug 2005
Feb 5th, 2006
0

Re: populating a listbox from another listbox dynamically??

<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>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
iwahdan is offline Offline
1 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: need help, to Search from database
Next Thread in ASP Forum Timeline: gulam soofi a learning web developer.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC