Jump to content

Window.onload Not Working With Doctype Declaration


confused and dazed

Recommended Posts

Hello internet.Here is my most recent dilemma. I have been creating WebPages without declaring a DOCTYPE. W3Schools forum members corrected that problem I was making. The issue now is that I have gone back and declared a doctype with all my pages and now I am cleaning up the problems. A big problem is getting the window.onload JavaScript function to work. Here is what I am doing, I am declairing this DOCTYPE<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> I am using the following javascript code - Tload is an array I created from mysql database $json = json_encode($rows);echo '<script type="text/javascript">var Tload = '.$json.';</script>';<script type="text/javascript">window.onload = function() {for (var i = 0; i < Tload.length; i++) { document.getElementById(Tload.id).value = Tload.value; } } The array values are not loading to my webpage... Please help.

Link to comment
Share on other sites

There's nothing wrong with that code in particular, assuming the rest of the page that you're trying to work with matches things that are in the Tload array. Make sure you're checking for Javascript errors. Print out the values in the array inside the loop to verify that you're trying to access the correct elements.

Link to comment
Share on other sites

O.K. so I had a small syntax error that was causing the problem. Did not close out a script properly.Now I have an error message expected object does this mean that the javascript remove files are not being called before the function is trying to run? Please help. I tried placing the javascript callout for the .js file inside AND then outside the form and it did not work either way. Please help.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...