Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic hiding/showing etc

Status
Not open for further replies.

Leozack

MIS
Oct 25, 2002
867
GB
Hi all, probably gonna sound dumb but I can't find the right answer to this. I have a page of search results andI'd like to hide some extra info for each one until they click a link or something to display it inline if they want to see the extra info. Might also have a close link to hide it again.

Anyway I've just gone round the houses with code that should work fine (was all fine 2 years ago in both IE6 and FF) but now FF2 debug (loveable tool) is complaining about IE only things like word-wrap and cursor:hand (which I can ignore despite filling my error screen with it, grrr) but more importantly I can't solve this hiding/showing business.

I have a couple of old js functions which should work fine
Code:
function ElemHide(elementname) {
	document.getElementById(elementname).style.display="none";
}
function ElemShow(elementname) {
	document.getElementById(elementname).style.display="inline";
}
Then for each search result I have tried various ways hiding/showing the info - I can put it into a div/span with an id of hiding35 or showing35 (where 35 is just the result number) for example or I can set them to a class but if I try hose js functions it firstly says "Warning: Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead." which is funy since tha's what I'm using, followed by "Error: document.getElementById(elementname) has no properties" which is less funny since it's stopping anything frmo working!

Also I've considered this only works if I'm hiding/showing 1 specific thing.

What if I have a few spans or tables per result I want to hide/show at a time? eg a table shows some items but if you click the link some other items appear (and possibly some alrady showing disappear) and then viceversa? This element-method must surely not be the ebst way to do that. But class-switching seems just as hard if I'm going to have lots of sets of this to handle?

I've done my head in and giving up for tonight, all ideas appreciated x_x

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
If you really want to do this in HTML then google for 'disjointed rollover' or take a look at the Contents panel on
If you want a JavaScript answer then try forum216

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top