473,796 Members | 2,864 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change <div>

I would like to know how I loop through a html file and validate it is the
type of element I am seeking and then change something in the element.

IE

for(x=0;x<this. document.elemen ts.length;x++)
{
if(this.element .type= = "<DIV>")
{
this.element.z-index=1;
}
}

sort of like a deck of cards, take the top one off and put it in the deck
then there is a new top card and the one placed in the deck has a new
z-index:.

Thanks
Apr 14 '06 #1
7 4611
Try this:

var divs = document.getEle mentsByTagName( "div");

for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;

if you need to get all the divs "under" a certain parent (container)
you could do this instead:

var divs = container.getEl ementsByTagName ("div");

Apr 14 '06 #2

This does not seem to work do you know what I am doing wrong?

http://www.wyght.com/warren/layers.html

that is the URL

--

Totus possum, totum Deum.
Totus ero, totum meum.
WSW

<oz*********@gm ail.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Try this:

var divs = document.getEle mentsByTagName( "div");

for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;

if you need to get all the divs "under" a certain parent (container)
you could do this instead:

var divs = container.getEl ementsByTagName ("div");

Apr 14 '06 #3
<oz*********@gm ail.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Try this:

var divs = document.getEle mentsByTagName( "div");

for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;

if you need to get all the divs "under" a certain parent (container)
you could do this instead:

var divs = container.getEl ementsByTagName ("div");


I got it working on IE but not on Modzilla here is the URL

http://www.wyght.com/warren/layers.html

Why does this work on IE but not Modzilla nor on NN?

--

Totus possum, totum Deum.
Totus ero, totum meum.
WSW
Apr 14 '06 #4
News wrote on 14 apr 2006 in comp.lang.javas cript:
<oz*********@gm ail.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Try this:

var divs = document.getEle mentsByTagName( "div");

for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;

if you need to get all the divs "under" a certain parent (container)
you could do this instead:

var divs = container.getEl ementsByTagName ("div");

This does not seem to work do you know what I am doing wrong?

http://www.wyght.com/warren/layers.html

that is the URL
[please do not toppost on usenet]
divs[x].style.id="hidd en"


There is no style called id.

If you ment divs[x].id,
you are not allowed to name two items the same id name.

Do not use <form> where a <div> is needed.

A for loop implementing what you want timeout-ed is not usefull.

I suppose you ment to use style.display, but visibility.hidd en works in the
same way, while preserving the "place".

try this:

=============== = test.html =============== ====

<style>
..a {display:none;}
</style>

<script type="text/javascript">

var x=0;
function myDiv() {
var top=0;
var you = document.getEle mentById('you') ; // necessary for non-ie
var divs = you.getElements ByTagName("div" );
if (x>0) divs[x-1].style.display= "none";
divs[x++].style.display= "block";
if (x<divs.length) setTimeout("myD iv();",300);
}

</script>

<body onload='myDiv() '>

<div id="you">
<div class="a">1</div>
<div class="a">2</div>
<div class="a">3</div>
<div class="a">4</div>
<div class="a">5</div>
<div class="a">6</div>
<div class="a">7</div>
<div class="a">8</div>
<div class="a">9</div>
<div class="a">10</div>
</div>

=============== =============== ======

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 14 '06 #5
News wrote:
<oz*********@gm ail.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Try this:

var divs = document.getEle mentsByTagName( "div");

for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;

if you need to get all the divs "under" a certain parent (container)
you could do this instead:

var divs = container.getEl ementsByTagName ("div");

I got it working on IE but not on Modzilla here is the URL

http://www.wyght.com/warren/layers.html

Why does this work on IE but not Modzilla nor on NN?


Because you have:

function myDiv()
{
var top=0;
var divs = you.getElements ByTagName("div" );
--------------^^^

Where 'you' is the id of the div. IE adds ids and names as global
variables that refer to the related DOM object, other browsers may mimic IE
in some circumstances[1], but not here. For them, 'you' is undefined, an
error is thrown and that's as far as the script goes.

It seems that what you want to do is make the n + 1 div visible each time.
So loop through until you find the visible one, make it hidden, then set
the next (or zero-th if at last div) to visible.

The rest of your script has so many errors that it surprising that it works
at all. Try:

<script type="text/javascript">
function myDiv()
{
// Declare variables
var you = document.getEle mentById('you') ;
var divs = you.getElements ByTagName("div" );
var numDivs = divs.length;
var x=0;

// Look for first non-hidden div
while (divs[x].style.visibili ty == 'hidden'){
++x;
}

// Set it to hidden
divs[x].style.visibili ty = 'hidden';

// Set the next or zero-th to visible
divs[++x % numDivs].style.visibili ty = 'visible';

// Set the timeout
setTimeout("myD iv();",100);
}
You need to add feature detection and replace the form element with a div.
1. This IE-ism was so pervasive that other browsers felt impelled to
implement IE's proprietary behaviour because of the number of issues it
caused. However, it is only supported in Gecko browsers where the DOCTYPE
is not strict or XHTML.
--
Rob
Apr 15 '06 #6
"RobG" <rg***@iinet.ne t.au> wrote in message
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au ...
News wrote:
<oz*********@gm ail.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Try this:

var divs = document.getEle mentsByTagName( "div");

for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;

if you need to get all the divs "under" a certain parent (container)
you could do this instead:

var divs = container.getEl ementsByTagName ("div");

I got it working on IE but not on Modzilla here is the URL

http://www.wyght.com/warren/layers.html

Why does this work on IE but not Modzilla nor on NN?


Because you have:

function myDiv()
{
var top=0;
var divs = you.getElements ByTagName("div" );
--------------^^^

Where 'you' is the id of the div. IE adds ids and names as global
variables that refer to the related DOM object, other browsers may mimic
IE in some circumstances[1], but not here. For them, 'you' is undefined,
an error is thrown and that's as far as the script goes.

It seems that what you want to do is make the n + 1 div visible each time.
So loop through until you find the visible one, make it hidden, then set
the next (or zero-th if at last div) to visible.

The rest of your script has so many errors that it surprising that it
works at all. Try:

<script type="text/javascript">
function myDiv()
{
// Declare variables
var you = document.getEle mentById('you') ;
var divs = you.getElements ByTagName("div" );
var numDivs = divs.length;
var x=0;

// Look for first non-hidden div
while (divs[x].style.visibili ty == 'hidden'){
++x;
}

// Set it to hidden
divs[x].style.visibili ty = 'hidden';

// Set the next or zero-th to visible
divs[++x % numDivs].style.visibili ty = 'visible';

// Set the timeout
setTimeout("myD iv();",100);
}

You need to add feature detection and replace the form element with a div.
1. This IE-ism was so pervasive that other browsers felt impelled to
implement IE's proprietary behaviour because of the number of issues it
caused. However, it is only supported in Gecko browsers where the DOCTYPE
is not strict or XHTML.
--
Rob


It works thanks and thanks for explaining what I was doing wrong

--

Totus possum, totum Deum.
Totus ero, totum meum.
WSW
Apr 17 '06 #7

"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ***********@194 .109.133.242...
News wrote on 14 apr 2006 in comp.lang.javas cript:
<oz*********@gm ail.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Try this:

var divs = document.getEle mentsByTagName( "div");

for (var i =0; i < divs.length; i++)
divs[i].style.zIndex = i;

if you need to get all the divs "under" a certain parent (container)
you could do this instead:

var divs = container.getEl ementsByTagName ("div");

This does not seem to work do you know what I am doing wrong?

http://www.wyght.com/warren/layers.html

that is the URL


[please do not toppost on usenet]
divs[x].style.id="hidd en"


There is no style called id.

If you ment divs[x].id,
you are not allowed to name two items the same id name.

Do not use <form> where a <div> is needed.

A for loop implementing what you want timeout-ed is not usefull.

I suppose you ment to use style.display, but visibility.hidd en works in
the
same way, while preserving the "place".

try this:

=============== = test.html =============== ====

<style>
.a {display:none;}
</style>

<script type="text/javascript">

var x=0;
function myDiv() {
var top=0;
var you = document.getEle mentById('you') ; // necessary for non-ie
var divs = you.getElements ByTagName("div" );
if (x>0) divs[x-1].style.display= "none";
divs[x++].style.display= "block";
if (x<divs.length) setTimeout("myD iv();",300);
}

</script>

<body onload='myDiv() '>

<div id="you">
<div class="a">1</div>
<div class="a">2</div>
<div class="a">3</div>
<div class="a">4</div>
<div class="a">5</div>
<div class="a">6</div>
<div class="a">7</div>
<div class="a">8</div>
<div class="a">9</div>
<div class="a">10</div>
</div>

=============== =============== ======

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


It is working now thanks for your help

--

Totus possum, totum Deum.
Totus ero, totum meum.
WSW
Apr 17 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3405
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to <foo/>) From XHTML specification:
1
2510
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody> <div> <span>
3
84618
by: Paul Thompson | last post by:
When I put a <div ...> inside a <table> specification, functionality is not there. When I put the <table> inside the <div> everything works. Why is that?
3
9846
by: Catherine Lynn Smith | last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on one layer to modify the content on another but I seem to keep running into errors. Basically I create a layer in the middle of the screen that initially comes up with a gif image of a house: <!-- start "house" layer definition for center of screen --> <DIV id="house" style="position:absolute; left:140px; top:137px; width:510px; height:325px; z-index:2"><img...
8
14467
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a page, there is a huge gap (like 3/8 inch or 25 px) between them. This is driving me bananas. What the hey am I missing? dh ------------------------------------------------ Dan Hansen ------------------------------------------------
3
3814
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644" onclick="__doPostBack('SitesRadioButtonList_3','')" language="javascript" />
28
5375
by: Kent Feiler | last post by:
1. Here's some html from a W3C recommendations page. <P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV> 2.Although I didn't think it would make any difference, I tried it with the </p>s included as well. <P>aaaaaaaaa</p><DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</p></DIV>
5
13560
by: Agix | last post by:
Hi there, Please check out : http://clarifysolutions.co.uk/certenroll/ The source is included below. This page is a test, so I can play about with paddings, margins and layouts using divs as semantically meaningless containers for bunch's of other elements - like everyone keeps telling me to make my code standards compliant. This request is not because I want a fix, but because I want to
8
10049
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF editor. A fellow member of the PCG has helped me by creating a bit of Javascript to emulate the scrolling and using Google I've now gotten it into a state where it almost passes the W3C Markup Validation Service. However, the one error, Error Line 166,...
0
9527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10172
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.