JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 3rd, 2005, 12:11 PM
ptcman ptcman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 2 ptcman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 36 sec
Reputation Power: 0
Dynamic Dependent Drop Down Boxes

I am using the following script to enable the use of dynamic dependent drop down boxes. Everything working correctly but on the child drop down box I need to display last names and first names of people. Currently it displays only last names. Any help is appreciated.

<tr>
<td><font size="1" face="Verdana"><b>Department</b></font></td>
<td> <font size="1" face="Verdana">
<select name="types" id="types" onChange="fillItems(0)">
<option selected> Select a Department:
<%
While (NOT types.EOF)
%>
<option value="<%=(types.Fields.Item("DepartmentID").Value)%>"><%=(types.Fields.Item("DepartmentName").Value)%></option>
<%
types.MoveNext()
Wend
If (types.CursorType > 0) Then
types.MoveFirst
Else
types.Requery
End If
%>
</select>
</font></td>
<td><font size="1" face="Verdana"><b>Employee </b></font></td>
<td> <font size="1" face="Verdana">
<select name="items" id="items">
<option selected> Select an Employee:


</select>
</font></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><font size="1" face="Verdana">
<input type="submit" value="Add" name="Submit1">
<input type="reset" value="Reset" name="B2">
</font></td>
<td>&nbsp;</td>
</tr>
</table>
</table>
<p>
<%'end if%>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
</body>
</html>
<script language="JavaScript">
var arItems = new Array()

arItems = [
<%
set objRS = server.CreateObject ("adodb.recordset")
objRS.open "Select departmentid, employeeid, employeelname, employeefname from employee order by employeelname",conn,1,3
arItems = objRS.GetRows()
objRS.Close()

for t = 0 to uBound( arItems, 2 )
response.Write( "[" & arItems( 0, t ) & "," & arItems( 1, t ) & "," & "'" & arItems( 2, t ) & "'" & "," & "'" & arItems( 3, t ) & "'" & "]" )
if t < uBound( arItems, 2 ) then response.Write("," & vbCrLf )
next
%>
]
function fillItems( intStart ) {
var fTypes = document.form1.types
var fItems = document.form1.items
var a = arItems
var b, c, d, intItem, intType

if ( intStart > 0 ) {
for ( b = 0; b < a.length; b++ ) {
if ( a[b][1] == intStart ) {
intType = a[b][0];
}
}
for ( c = 0; c < fTypes.length; c++ ) {
if ( fTypes.options[ c ].value == intType ) {
fTypes.selectedIndex = c;
}
}
}

if ( intType == null ) {
intType = fTypes.options[ fTypes.selectedIndex ].value
}
fItems.options.length = 0;
for ( d = 0; d < a.length; d++ ) {
if ( a[d][0] == intType ) {
fItems.options[ fItems.options.length ] = new Option( a[d][2], a[d][1] ); // no line-break here
}
if ( a[d][1] == intStart ) {
fItems.selectedIndex = fItems.options.length - 1;
}
}
}
</script>





<%
types.Close()
Set types = Nothing
%>

Reply With Quote
  #2  
Old June 3rd, 2005, 12:28 PM
ptcman ptcman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 2 ptcman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 36 sec
Reputation Power: 0
I think it has something to do with thus line

fItems.options[ fItems.options.length ] = new Option( a[d][2], a[d][1] ); // no line-break here

In the above line of code if I change the a[d][2] to a[d][3], the person's first name appears in the child drop box. If just add a[d][3] to make " a[d][3], a[d][2], a[d][1] " only the first name appears. I have played around with this line by placing the a[d][3] in different positions but I still don't see how to make it display firstnames and lastnames.

Reply With Quote
  #3  
Old June 6th, 2005, 08:35 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Is it possible to present us with a script after your serverside code has run?
It's easier to debug Javascript from the client side

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Dynamic Dependent Drop Down Boxes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway