Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 5th, 2003, 08:26 PM
Registered User
 
Join Date: Nov 2003
Location: Toluca Lake, California, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default using asp to write javascript

I am working on a page where the javascript needs to be dynamically written depending on the content for the page. The content for the page is determined with VBScript.

I have tried to write the javascript with <% asp vbs code%> inserting the vbscript variables, but that is not working.

Is there a way to write the javascript server side using asp so it will work client side?

thanks!
  #2 (permalink)  
Old November 5th, 2003, 09:36 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

vivalet,
What you have tried is the way to do it.
You can fill in the dynamic vaiables with <%= variableName%> or you can write the entire code in a string if it suits better.
eg
Code:
<%
response.write("<script language=javasccript>")
response.write("function alertMe()")
response.write("{alert('This is me')}")
response.write("</script")
%>
If this is not working for you try a very simple example and build on it.
I often use dynamic js in this fashion and it can be a useful tool

Rod

======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
  #3 (permalink)  
Old November 5th, 2003, 09:45 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

If writing js <script> tags with vbs, be carefull not to place them inside existing script tags on the page.


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
  #4 (permalink)  
Old November 6th, 2003, 02:02 PM
Registered User
 
Join Date: Nov 2003
Location: Toluca Lake, California, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks,rodmcleay! this is exactly what I needed. And it now works!

Quote:
quote:Originally posted by rodmcleay
 If writing js <script> tags with vbs, be carefull not to place them inside existing script tags on the page.


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================


Similar Threads
Thread Thread Starter Forum Replies Last Post
hi help me to write javascript to validate textbox karthikc85 XML 1 October 12th, 2006 03:12 AM
javascript to write out two different time zones crmpicco Javascript How-To 2 May 25th, 2006 10:55 AM
How to write a message board with javascript ? shenliujun Javascript 0 September 5th, 2004 07:36 PM
ASP Table write out aware Classic ASP Basics 2 September 18th, 2003 02:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.