Forum Moderators: open

Message Too Old, No Replies

What argument should I use ?

Click a check box and check all boxes inside a form in an iframe

         

bleak26

7:51 am on Mar 8, 2009 (gmt 0)

10+ Year Member



Hi,

I have a check box which needs to check all or uncheck all, boxes inside a form in an iframe. to be precise the onclick is outside the iframe which contains the form which is called mylist. this is the script i am using.


function checkAll(checkname, exby) {
for (i = 0; i < checkname.length; i++)
checkname[i].checked = exby.checked? true:false

}

This code starts the process


<input name="catagory" type="checkbox" onClick="checkAll(document.mylist,this)" >

the current argument is document.mylist. What argument should i use to pass the mylist form in the iframe to the function checkAll? The iframes id and name is profilewindow. the checkAll function is included in both documents.

Thankyou in advance for any help.

daveVk

11:29 am on Mar 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In place of document.mylist try
document.getElementById('profilewindow').document.mylist

btw
checkname[i].checked = exby.checked? true:false
can be written
checkname[i].checked = exby.checked;

bleak26

4:52 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



Hi daveVK, thankyou for the quick reply. i have added the new code but so far it is not working.

This is the error i get in the firefox java script error console

document.getElementById("profilewindow").document is undefined

I am sure the ids i gave are correct. is there any reason it might not be able to find the element? is there a way to see what elements are avalible to java script at run time?

daveVk

11:23 pm on Mar 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



add this function

function getIframeDoc( idStr ) {
var iframe = document.getElementById(idStr);
return iframe.contentDocument ¦¦ iframe.contentWindow.document;
}

argument becomes

getIframeDoc("profilewindow").mylist