confused and dazed Posted January 9, 2012 Share Posted January 9, 2012 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 More sharing options...
justsomeguy Posted January 9, 2012 Share Posted January 9, 2012 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 More sharing options...
confused and dazed Posted January 9, 2012 Author Share Posted January 9, 2012 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 More sharing options...
justsomeguy Posted January 9, 2012 Share Posted January 9, 2012 If the error is on the line inside the loop, then it sounds like the element doesn't exist. Link to comment Share on other sites More sharing options...
confused and dazed Posted January 9, 2012 Author Share Posted January 9, 2012 Everything was working fine in the browser I was working with (IE) until I added the DOCTYPE... All I am doing is clicking a submit button and this is the error I am getting... Link to comment Share on other sites More sharing options...
justsomeguy Posted January 9, 2012 Share Posted January 9, 2012 I can't really say much with seeing only this. Figure out which line the error is on, if you need additional help post the rest of the code. Link to comment Share on other sites More sharing options...
confused and dazed Posted January 9, 2012 Author Share Posted January 9, 2012 I'm going to go away now...Me and my syntax problems need to work things out...Once again a simple syntax problem. Sorry for wasting your time. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.