Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling client-side fnc w/o using <body onload...>

Status
Not open for further replies.

justElizabeth

Programmer
Sep 9, 2002
1
US
I am retrieving an array of data from the server and need to populate a global client-side array so that it is available to populate data on my ASP when the user selects something from a list.

For example the user selects a person and I want to fill in the person's title, phone, and .....

In order to do this from the client I need to populate a global array on the client from the server. I usually do this with the <body onload> feature ... HOWEVER I've got an include file that someone else wrote that is required in the ASP. When it is included the <body> onload doesn't fire.

THE QUESTION: is there some other way to do this?

Hope I've given enough info and thanks in advance,

elizabeth.
 
if you use ASP to generate your html/javascript page, what you can do is to generate a javascript array (something like this :
<head>
<script type=&quot;text/javascript&quot;>
my_array = new array();
my_array[0] = &quot;some_val&quot;;
...
my_array[154] = &quot;some other value&quot;;
</script>
</head>)

then, from every place in your page you can call my_array[some_index] as it's a javascript array client side.

 
If I understand you correctly, the function is in the other page that needs to be included, right? If it is a javascript file, just do this to include it (If it isn't a js file, include it however you would do that in ASP):

<script src=&quot;filename.js&quot;></script>

If you put that in the head, then you can call the function like this:

<body onLoad=&quot;function_name()&quot;>

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top