[thelist] IE javascript question

Eduardo Kienetz eduardok at gmail.com
Mon Jul 2 09:04:56 CDT 2007

Hi ppl :)

I came across a problem in IE which makes the javascript that follows
not to work properly.

In my form I have this button:
<input type="submit" name="submit2" value="ADD" class="formbranco"
onClick="return verificaMarcacao('Please select at least one

Which when clicked should check if at least one checkbox is checked,
using this javascript function:

function verificaMarcacao(msg){
   var i,tmp,ind,txt,sel;
   sel = document.getElementById('amostra').selectedIndex;
      tmp = document.getElementById(examesmats[sel][i]);
      if(tmp.childNodes[0].childNodes[1].checked) return true;
   return false;

I'm guessing this has something to do with childNodes, but I was
unable to confirm (much less to tell why).

And, before someone asks, I'm passing the message as a parameter
because this javascript is static (on a .js file), but the message is
internationalized. So, that means the form could have this (which
doesn't matter to solve the problem):
<input type="submit" name="submit2" value="ADD" class="formbranco"
onClick="return verificaMarcacao('Por favor selecione pelo menos um

Now, what happens is that even selecting a checkbox Internet Explorer
shows the message.
The item to be checked looks like this:
<div id="EX_AATD" class="hiding"><label> <input type="checkbox"
name="EX_AATD">Item 1</label></div>

This DIV is what I get from: tmp = document.getElementById(examesmats[sel][i]);
Thus, explaining my use of childNodes[0] and then [1]

Should I use getElementByName? Is it okay (not deprecated, etc) ?

Thank you in advance,

Eduardo Bacchi Kienetz
LPI Certified - Level 2

More information about the thelist mailing list