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 a javascript procedure from an ASP page

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
i'm trying to call a javascript procedure from an ASP page... i can do it thru a link like so: [HREF='javascript:ViewInvenWO(&quot;<%=loRecordset(&quot;wo_num&quot;)%>&quot;)'><%=loRecordset(&quot;date_rcvd&quot;)']

but how would i do it directly as i execute/include an ASP page?? what would the syntax be??

thanks for any help. mike.
 
You should be careful executing JavaScript functions as the page loads, in that you need to make sure that any elements or procedures that the function is trying to access have already been written to the browser. A very popular way to execute a JavaScript function on page load is to place the function in the onLoad event handler which is placed in the body tag. So here are your two options.

Anywhere in the body of the HTML you can write this.

Code:
<script Language=&quot;JavaScript&quot;>
<!--
ViewInvenWO('<%=loRecordset(&quot;wo_num&quot;)%>')
//-->
</script>

That will execute the function at the moment it is written to the page. Of course, you must have already written the function on the page, usually between the <head></head> tags.

Or you can do this.

Code:
<body ..blah.. ..blah.. onLoad=&quot;ViewInvenWO('<%=loRecordset(&quot;wo_num&quot;)%>')&quot;>

Now, I noticed that you have double quotes around the parameter that you are passing to the function. This is fine, but I changed them to single quotes which works just the same. If you want the function to treat the passed parameter as a number, remove the single quotes alltogether.

Hope this helps :)

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top