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

Manipulating the Sequence of DIVs on page

Status
Not open for further replies.

R3D3

Programmer
May 1, 2002
34
FR
can anyone think of a way of manipulating the Sequence of DIVs on a page?
I'm trying to find a way of displaying the first few DIVs on a page and then inserting another, the position being dependendent upon its content.
I can make the DIVs hidden as below but can I then make them visible in a different position?

I can wait till the whole page is there and the re-sort the whole lot, but where is the fun in that?


<script language=&quot;javascript&quot;>
function test(xxxxx)
{
xxxxx.style.visibility=&quot;hidden&quot;;
}
</script>

</head>

<body>
<form name=&quot;form&quot; onsubmit=&quot;return test(document.form)&quot; method=&quot;post&quot;>
<Div id=x0001 onClick=&quot;return test(x0001)&quot;>Div One</Div>
<Div id=x0002 onClick=&quot;return test(x0002)&quot;> Div Two</Div>
<Div id=x0005 onClick=&quot;return test(x0005)&quot;> Div Five</Div>
<Div id=x0004 onClick=&quot;return test(x0004)&quot;> Div Four</Div>
<Div id=x0003 onClick=&quot;return test(x0003)&quot;> Div Three</Div>

</form>
</body>
 
HI,

You can do this for sure with absolute positioning. It would require keeping track of the Height of each DIV. When you make one disapear the ones below move up by the height of the one that disapears. Opposite for reapearing.

You can search the Javascript forum for more help on this but here is how to absolute position:
<div id=&quot;MYDIV&quot; style=&quot;position:absolute;left: 30px; top: 30px&quot;>blah blah</div>

just keep track of the &quot;top&quot; position and change it with javascript.

have fun.


Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top