Click here to register.
      
Sprechen Sie WebGUI? Parlez vous WebGUI? Se habla WebGUI? Spreekt u WebGUI?

Do you speak WebGUI? Please help us translate WebGUI into your language.



     Discuss > Etcetera

Help with show hide JS

User sandraqu
Date 8/18/2008 3:22 pm
Views 637
Rating 1    Rate [
|
]
Previous · Next
User Message
sandraqu

I have a simple script, that I am getting an eternal object required error with in IE.  this is only a simplified version of the script in an attempt to pin point the issue.  This is an external script being instigated by an removed event in the HTML.

Tips much appreciated.

function toggleDiv(id){
alert(id); // show_hide - correct value for id
obj = document.getElementById(id);
alert(obj); // null -  where id my value go?
if (obj.style.display == "none"){ // this line hits obj. required err
obj.style.display = "";
} else {
obj.style.display = "none";
}
}

--- (Edited on 8/18/2008 3:22 pm [GMT-0500] by sandraqu) ---



Back to Top
Rate [
|
]
 
 
rogier

I'm no javascript expert, but if the variable "obj" isn't declared elsewhere:

function toggleDiv(id){
alert(id);
var obj = document.getElementById(id);
alert(obj);
if (obj.style.display == "none"){
 obj.style.display = "";
}else {
 obj.style.display = "none";
}
}

 

Rogier | United Knowledge
www.unitedknowledge.nl · www.webgui-help.nl

--- (Edited on 19-08-2008 8:16 pm [GMT+0200] by rogier) ---



Back to Top
Rate [
|
]
 
 
sandraqu

rogier, thanks for the reply.

i have a better one for you, the script was working perfectly.  it was complaining because there was no such ID declared in the HTML of that particular article i used to test with.  Bleh bleh... what a brain fart.

Despite the mishap, what I ended up doing was adding a conditional

if ( document.getElementById(id) ) {
//run my script
}

and this did wonders because I was able to use one template style throughout this particular section of the website.

To give a little background: the script (in it's entirety - not shown here) shows and hides Endnotes.  So we have articles, and if someone wants to see the endnotes (both the little numbers within the article, and the actual endnotes at the end of the article) they click 'Show Endnotes' and wallah! Not all documents have endnotes, so the conditional above helps a lot in avoiding error alerts since there's no <div id="#endnote">list of endnotes</div> in some articles.

The script also toggles 'Show Endnotes' to 'Hide Endnotes' when clicked and vice versa; it also shows (or hides) 'Show Endnotes' if <div id="#endnotes"> exists (or not).  They work well as a team.

Just in case anyone has need for it... lemme know.

--- (Edited on 8/19/2008 3:02 pm [GMT-0500] by sandraqu) ---

--- (Edited on 8/19/2008 3:03 pm [GMT-0500] by sandraqu) ---



Back to Top
Rate [
|
]
 
 
     Discuss > Etcetera



Recent Discussions Color Key

Design:

Development:

Et Cetera:

Install/Upgrade:  

Smoketest:

Template Group:


Re: Navigation links by techwriter - Fri @ 03:23pm

Re: Best way to make files available to webgui comunity by bernd - Fri @ 02:50pm

Re: User event history by knowmad - Fri @ 02:02pm

Re: Best way to make files available to webgui comunity by lctn2 - Fri @ 01:55pm

Re: Strategic Roadmap by JT - Fri @ 01:55pm

Re: Navigation links by rogier - Fri @ 01:55pm

Re: 2009 Presidents Meeting by JT - Fri @ 01:10pm

Re: navigation new window by rogier - Fri @ 01:03pm

Re: navigation new window by rogier - Fri @ 12:53pm

Re: WUC 2009 by JT - Fri @ 12:50pm

Re: Best way to make files available to webgui comunity by preaction - Fri @ 12:35pm

Re: Pagination markup by rogier - Fri @ 12:35pm

Re: Best way to make files available to webgui comunity by kristi - Fri @ 12:29pm

Debian and Ubuntu Packaging Status by jmarsden - Fri @ 12:12pm