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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DIV ID & Show/Hide

Status
Not open for further replies.

pouet

Programmer
Jan 31, 2003
3
CA
Hello,

I'd like to know how I can access the ID in a DIV tag to change his name? For an image, I can access the src with document[0].src=... and I want something like that to assign the ID of my DIV tag with a Javascript function. The goal is to generate specific ID with Javascript.

Another Question: in Javascript, I use function to Show/Hide DIV but is it possible to Hide a DIV and Show another DIV over it? I want to call a DIV that replace another DIV. But when I Show DIV1 and I Hide it to Show DIV2, DIV2 doesn't replace DIV1 but appear after DIV1 which is hidden. How can I change this?

Thanks,
 
your_object.id="whatever" will set the id of the object "your_object" to "whatever"

and about show/hide, you should go in this order : first hide div2 then show div1
but they have to be positionned
and beware of the browser : if it works for 1 it's likely not to work for &quot;the other&quot; (for example, in ie you write : &quot;hidden&quot; and in ns<6 you write &quot;hide&quot;)
 
Thank You,

You say that the DIV have to be positionned but how do you do that because I want these DIV to be positionned after some HTML text which length can change(depend on the user selection). The position should not be static but relative, in other words I'd like to make appear these DIV at the same place. In my example when the user click on a specific image(subject) it shows another image(subject element) with some text(that comes from my DIV1) and when the user click on another image the new subject element(my DIV2) should appear on the old subject element.
Is it still possible to do?
 
in the style section of the div, do:
style=&quot;position: relative;&quot;

ray
rheindl@bju.edu

 
I'm not sure you can relatively position two layers over each other. By definition, relative positioning causes the layers to be placed in the order that they were defined. Maybe setting the z-index differently will solve that, but I don't think so. If you want both layers in the same x,y order, but a different z order, then I think you will have to absolutely position them. Try to make it so that your other content can also be absolutely positioned and still leave room for expansion.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top