No, its not correct to state that (look at my dev site again, it is full of page elements "pulled via Ajax" and accessed by javascript). You just wont find the element using getElementById etc.
For example, lets say I have the following form, loaded into the page using Ajax:
<form name="elemTest" id="elemTest" onsubmit="return checkCheckBoxes();" action="">
<input type="checkbox" name="box_1" value="1">1</p>
<input type="checkbox" name="box_2" value="2">2</p>
<input type="checkbox" name="box_3" value="3">3</p>
<input type="submit" value="Submit" />
</form>
On my main page that the Ajax content is loaded into, the following will work in IE but not Firefox and others:
<SCRIPT TYPE="text/javascript">
<!--
function checkCheckBoxes() {
var dname = document.getElementById('elemtest');
if (dname.box_1.checked == false &&
dname.box_2.checked == false &&
dname.box_3.checked == false)
{
alert ('Please choose one of the checkboxes!');
return false;
}
else
{
return true;
}
}
//-->
</SCRIPT>
While this will work in all:
<SCRIPT TYPE="text/javascript">
<!--
function checkCheckBoxes() {
if (document.elemTest.box_1.checked == false &&
document.elemTest.box_2.checked == false &&
document.elemTest.box_3.checked == false)
{
alert ('Please choose one of the checkboxes!');
return false;
}
else
{
return true;
}
}
//-->
</SCRIPT>
HTH
Matti Ressler
Suomedia
Last edited by Suomedia : Mar 17th, 2008 at 7:39 pm.