Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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>

Reply With Quote
  #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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:31 PM.


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