Jump to content

stupid n00b question


yoshida

Recommended Posts

This may be a stupid n00b question, but how do I call a javascript function without using an event trigger? I'd like to populate some divs with data, both the source data and the target divs defined by a parameter. That means I have to call the function, an XmlHttpRequest, multiple times.I'll search my library for answers, helpful suggestions are welcome in the meantime.

Link to comment
Share on other sites

You can do this:

<html>	<head>		<title>Titled Document</title>		<script type="text/javascript">			function main(){				alert('I\'m in...');			}			main();		</script>	</head>	<body>	</body></html>

The problem with this method is that the page isn't loaded, and page elements aren't available when main() is called. (Why must you avoid using event handlers?)Does anyone else have another way?

Link to comment
Share on other sites

Here I am looking for the long way around...I thought of creating an array, and have it populate the page using a WHILE loop. But I bashed my head against the wall in stupidity after two lines of code.I used PHP for this one instead, opening the specified DIV, call <?php require_once('script.php') ?> and closed the DIV.It's the easiest way since it's a management page for my new CMS after all.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...