Jump to content

getElementById troubles(solved)


GingerRobot

Recommended Posts

Ok, i have solved my previous problem but have another so i might as well just modify this topic.

why does this:
parent.document.all.due.value=date;
work, and not this:
parent.document.getElementById('due').value=date;

As i understand it, you shouldn't use all anymore, but use getElementById, and certainly Firefox gives a warning although it still functions.

Any help would be much appreciated.

Thanks, Ben
Link to comment
https://forums.phpfreaks.com/topic/16711-getelementbyid-troublessolved/
Share on other sites

Try to stick to methods and props defined in the DOM level 2 W3C recommendation, and implement fixes for IE.

[code]document.getElementById('due').nodeValue = date;[/code]

Should work in at least IE6 and FF, not sure about all versions of IE5.

You might have to use a little [url=http://"http://javascriptkit.com/javatutors/objdetect2.shtml"]object detection[/url].

Some older versions of IE use the "document.all" model, which sucks, but is better than nothing:

[code]if (!document.getElementById) {
      if(!document.all)  {
        //DOM not supported :'(
        return;
        }
            else {
            //Document.all model
            document.all.due.value=date;
        }
}
        else {
        //W3C DOM
        document.getElementById('due').nodeValue = date;
}[/code]

FF did partly adopt Microsoft's document.all model for older sites still using it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.