Same script - different setting?

U

UKuser

Hi,

The following script:

function isTick(id){
if (document.getElementById(id).checked == true){
alert(id+" is ticked");
}
}

Very simple sample script just to check that the box is ticked.

It WORKS where it is featured here:

</head>
<body>

<form action="">
<p><input type="checkbox" onclick="checkAll('a',4,this.id);"
id="Europe">Europe <span onclick="ShowHideLayer(156);">[Show/Hide]</
span></p>
<div id="box156" class="collapsible">
This layer is now visible and it moves content down the page with
it!<br>
a1: <input type="checkbox" id="a1" onclick="checkStatus(this.id,
4,'Europe');isTick(this.id);"><br>

however it FAILS when it is featured here:
<form action="">
<div class="mainDiv" title="0">
<input type="checkbox" onclick="checkAll('a',4,this.id);"
id="Europe">Europe
<div class="topItem">
<span onmouseover="Init(this.parentNode);">[Show/Hide]</span>
</div>
<div style="height: 0pt;" class="dropMenu">
<div class="subMenu" title="0">
a1: <input type="checkbox" id="a1" value="yes"
onclick="checkStatus(this.id,4,'Europe');isTick(this.id);"><br>

My Q is therefore why is getElementbyID not picking up the checked
status in the second example, only the first?

Thanks and have a good weekend.

A
 
U

UKuser

Hi,

The following script:

function isTick(id){
if (document.getElementById(id).checked == true){
alert(id+" is ticked");
}
}

Very simple sample script just to check that the box is ticked.

It WORKS where it is featured here:

</head>
<body>

<form action="">
<p><input type="checkbox" onclick="checkAll('a',4,this.id);"
id="Europe">Europe <span onclick="ShowHideLayer(156);">[Show/Hide]</
span></p>
<div id="box156" class="collapsible">
This layer is now visible and it moves content down the page with
it!<br>
a1: <input type="checkbox" id="a1" onclick="checkStatus(this.id,
4,'Europe');isTick(this.id);"><br>

however it FAILS when it is featured here:
<form action="">
<div class="mainDiv" title="0">
<input type="checkbox" onclick="checkAll('a',4,this.id);"
id="Europe">Europe
<div class="topItem">
<span onmouseover="Init(this.parentNode);">[Show/Hide]</span>
</div>
<div style="height: 0pt;" class="dropMenu">
<div class="subMenu" title="0">
a1: <input type="checkbox" id="a1" value="yes"
onclick="checkStatus(this.id,4,'Europe');isTick(this.id);"><br>

My Q is therefore why is getElementbyID not picking up the checked
status in the second example, only the first?

Thanks and have a good weekend.

A

Ignore me - the div is set to invisible which surprises me that it
isnt displayed but if the css display:none is removed it does work -
so its just the invisiblility issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top