"Anna" <> wrote:
> And what I actually want to do, is to check only the text boxes
> that are not inside invisible divs.
> Is there a way to say in javascript something like:
> choose only textbox that is not inside element (div) whose
> className='invisible'?
function contains(parent,child){
if (parent==child) return true;
var t = child;
if (t && t.parentNode){
if (t.parentNode == parent)
return true;
else
return contains(parent,t.parentNode)
}
return false;
}
var myForm=document.getElementById("your_form_id");
var invisibleDivs=new Array();
var divs=myForm.getElementsByTagName("DIV");
for (var i=0; i<divs.length; i++){
if (divs.item(i).className == "invisible")){
invisibleDivs.push(divs.item(i));
}
}
var textBoxes = myForm.getElementsByTagName("INPUT");
for (var i=0; i<textBoxes.length; i++){
var currentTxtBox = textBoxes.item(i);
if (currentTxtBox.type == "text"){
var good=true;
for (var j=0;j<invisibleDivs.length;j++){
if (contains(invisibleDivs.item(j),currentTextBox)){
good=false;break;
}
}
if (good){
//your code here
}
}
}
Not tested.
Good luck,
Vjekoslav
|