Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
| Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP 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 June 20th, 2008, 09:30 AM
Authorized User
 
Join Date: Jun 2008
Location: , , .
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access ASP code inside Javascript

Hello,

I have a problem. I have ASP code and Javascript code. Now, I want to access ASP code inside javascript code.

Here is the ASP code:
<%
CONST C_prefix = "contains(.,'"
CONST C_midfix = "') or contains(.,'"
CONST C_suffix = "')"

Function CreateContainsList( fromStr )
    Dim temp, re
    ' the regexp ensures that multiple spaces become single spaces
    Set re = New RegExp
    re.Pattern = "\s+"
    re.Global = True
    ' so get an array of words via split...
    temp = Split( re.Replace( Trim(fromStr), " " ), " " )
    ' and make it into the contains list via join and helpers
    CreateContainsList = C_prefix & Join( temp, C_midfix ) & C_suffix
End Function

demo = " My Little Black Book "

path = "form/document[" & CreateContainsList(demo) & " ]//*"

Response.Write "<pre>" & demo & "" & path & "</pre>"
%>

And I want to print variable "demo" inside javascript.

I tried like this but the demo does not print out.
<script type="tex/javascript">
document.write(demo);
</script>

  #2 (permalink)  
Old June 20th, 2008, 02:00 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You posted in the wrong forum. This forum is for *JSP*. Which has nothing whatsoever to do with *ASP*.

The answer to this question, though, is the same in either JSP or ASP:

<script type="tex/javascript">
document.write("<%=demo%>");
</script>

Now move your post to an ASP forum.


Similar Threads
Thread Thread Starter Forum Replies Last Post
generating javascript arguments inside ASP script cookster Classic ASP Professional 0 November 24th, 2007 03:56 PM
access javascript global variable in code behind dsekar_nat ASP.NET 1.0 and 1.1 Professional 1 March 14th, 2006 01:39 AM
ASP variable inside my JavaScript crmpicco Javascript How-To 1 June 4th, 2005 12:17 AM
set ASP variable values inside Javascript crmpicco HTML Code Clinic 1 March 9th, 2005 12:32 PM
Javascript question in my ASP code savoym Classic ASP Basics 3 May 24th, 2004 06:05 PM





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