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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 26th, 2004, 07:42 AM
gbaia gbaia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 24 gbaia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Expandable list

hello!

I have a javascript form integrated with asp that does expandable lists...

Basically, I select the categories, do a loop to display them, and when the user clicks on one of them, he has a list of the sub-categories which are related to the category clicked.

My javascript is pretty bad, but, my asp is ok. I'm struggling to find out how to change the javascript code so that, if the users click and there are no sub-categories, they go to another page.

Thanks so much for any help!

The code is as below:

javascript:

<SCRIPT LANGUAGE="Javascript">
<!--
function over(evt) {
if (document.all) {
var src = event.srcElement;
var parent = src.parentElement;
} else {
var src = evt.target;
if (src.nodeType == 3) src = src.parentNode;
var parent = src.parentNode;
}
if (("SPAN" == src.tagName && parent.className != '')) {
src.style.color = "rgb(255,0,0)";
src.style.cursor = (document.all) ? "hand" : "pointer";
}
}
function out(evt) {
if (document.all) {
var src = event.srcElement;
var parent = src.parentElement;
} else {
var src = evt.target;
if (src.nodeType == 3) src = src.parentNode;
var parent = src.parentNode;
}
if (("SPAN" == src.tagName && parent.className != '')) {
src.style.color = "rgb(0,0,0)";
src.style.cursor = "auto";
}
}
function getChildElement(obj, childNum) {
var child = 0;
if (obj.hasChildNodes()) {
for (var i=0; i < obj.childNodes.length; i++) {
if (obj.childNodes[i].nodeType != 1) continue;
if (child != childNum) {
child++;
continue;
} else
return obj.childNodes[i];
}
}
return null;
}
function showIt(evt) {
var child = null, parent;
if (document.all) {
var src = event.srcElement;
var parent = src.parentElement;
} else {
var src = evt.target;
if (src.nodeType == 3) src = src.parentNode;
var parent = src.parentNode;
}
if (("SPAN" == src.tagName && parent.className != '')) {
/* IE 5 will also execute the getChildElement function but not IE 4.0
* That is the reason why the document.all reference is used here for IE */
child = (document.all ? document.all[src.sourceIndex+1] : getChildElement(parent, 1));
if (null != child && "LI" == parent.tagName && "UL" == child.tagName) {
parent.className = ("close" == parent.className ? "open" : "close");
child.className = ('expanded' == child.className ? 'none' : 'expanded');
}
}
}
//-->
</SCRIPT>

And the bit where the javascript is used is:

do while not(rs.eof)
CatID = rs("Link_Category_ID")
cat=rs("Link_Category")
%>

<UL CLASS="toc" ONMOUSEOVER="over(event);" ONMOUSEOUT="out(event);" ONCLICK="showIt(event);">
<LI CLASS="close"><SPAN><%=cat%></SPAN>

<UL>

<%sql2="select * from list_link_category Where Parent_ID = "&CatID
Set rs2 = cn.execute (sql2)

'If not rs2.EOF Then
do while not rs2.EOF
%>

<LI><%=rs2("Link_Category")%></LI>
<%rs2.MoveNext
loop%>
</UL>
<%'Else
'response.Redirect ("list.asp?cat="&cat)
'End If
%>
</LI>
</ul>

<%
rs.movenext
loop
%>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Expandable list


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 2 hosted by Hostway