WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Site Design > Graphics & Design Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Graphics & Design Discussion Forum Post your graphics design questions/comments/ideas in here. Ask questions, post tutorials, discuss trends and best practices. Sub-forum for website accessibility and usability.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-25-2006, 07:16 PM
WebProWorld New Member
 

Join Date: Sep 2005
Location: United States of America
Posts: 15
WWWDesignWizard RepRank 0
Default getElementsByName Problem

Hello all!

I seem to have run into a quite frustrating problem involving JavaScript and the getElementsByName method.

What I am trying to do involves a expand/collapse content script. I got the content to expand and collapse fine, but along with the content expanding and collapsing I would like to have the arrow image which triggers the change (when the user click the image) to also change depending on the current status of the content.

In short, I want the arrow image to change depending on whether the content is collapsed or expanded.

What I have coded works fine with one image, but when I have more than one collapsible/expandable block of content (which means more than one arrow) I can't get the arrow that cooresponds to the content being changed to change.

What I am trying to do is use the getElementsByName method to change the arrow with the name that is also the ID of the content DIV.

With the code I currently have, when I click the arrow to expand the content the arrow completely disappears and the content does not expand. I can't seem to figure out what is causing this. When I call "document.getElementsByName(Result).src" before the function (to see if it's getting the correct image URL) using an alert message I get an output of "undefined." Why is this outputting "undefined" instead of the URL of the current image?

If anyone has any ideas or has a possible solution to make the arrows change on click it would be greatly aprreciated.

Code:
<HEAD>

<SCRIPT>
function DispContent(Result)
{
  if(document.getElementById(Result).style.display == "none")
	{
    document.getElementById(Result).style.display = "block";
		document.getElementsByName(Result).src = "Images/Arrow_Expanded.gif";
  } 
  else
	{
    document.getElementById(Result).style.display = "none";
		document.getElementsByName(Result).src = "Images/Arrow_Collapsed.gif";
  }
}
</SCRIPT>

</HEAD>

<BODY>
[img]Images/Arrow_Collapsed.gif[/img] <B STYLE="margin-left: 5px;">On Sunday, January 01, the Pine-Richland Rams took on Null.[/b]
<DIV ID="010100" STYLE="display: none;">


<TABLE BORDER="0" FRAME="void" RULES="none" CELLSPACING="0" CELLPADDING="0" CLASS="Results">
<TR>
<TD WIDTH="70">Men:</TD>
<TD WIDTH="65">PR - 00</TD>
<TD WIDTH="65">Null - 00</TD>
</TR>
<TR>
<TD WIDTH="70">Women:</TD>
<TD WIDTH="65">PR - 00</TD>
<TD WIDTH="65">Null - 00</TD>
</TR>
</TABLE>



<FONT COLOR="#303030" CLASS="Results_Highlights" STYLE="font-weight: bold; font-style: italic;">Ram Highlights:</FONT>



<SPAN CLASS="Results_Highlights">Men:</SPAN>
<UL STYLE="margin-top: 5px;">
<LI CLASS="Results_Highlights">Lorem ipsum.</LI>[/list]<SPAN CLASS="Results_Highlights">Women:</SPAN>
<UL STYLE="margin-top: 5px;">
<LI CLASS="Results_Highlights">Lorem ipsum.</LI>[/list]</DIV>
</BODY>
I do not have the webpage uploaded yet, but if it would make debugging easier by looking at the entire source I don't mind uploading it.

Thanks again for any comments, suggestions, and help! ^_^

Regards,
Mike
__________________
Wise WizardsŪ Website Design :: Professionally Designed Websites at Affordable Prices :: http://WiseWizards.com
Reply With Quote
  #2 (permalink)  
Old 06-28-2006, 10:29 AM
sands's Avatar
WebProWorld Veteran
 

Join Date: Sep 2005
Location: Kerala, India
Posts: 397
sands RepRank 1
Default

Sorry, no time to go through your code, but why do you want to have images? If text (+ and -) would do for you, check out this script:
http://www.sivamdesign.com/scripts/dwld/col_menu.html
__________________
My Nook | My Biz
Reply With Quote
Reply

  WebProWorld > Site Design > Graphics & Design Discussion Forum
Tags: ,



Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0