Jump to content
Sign in to follow this  
yoshida

stupid n00b question

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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

you just call the function like in the example above just after the last element you need to use.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...