Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > passing asp string value to client side javascript

Reply
Thread Tools

passing asp string value to client side javascript

 
 
Brendan
Guest
Posts: n/a
 
      09-11-2007
I have the following asp page in which I need to generate images
filenames from asp variables and pass these to the client side
javascript that will animate the images. The code below does not work.
How do I pass the filenames to the ajvascript. The code below does not
do it and I do not understand why.


<head>
<%
dim zulu, zone, field, depth, image_base_name, image_name(4),
zulu = Request.QueryString("zulu")
zone = Request.QueryString("zone")
field = Request.QueryString("field")
depth = Request.QueryString("depth")
if depth = "nodepth" then
image_base_name = "upload/" & zulu & "_" & zone & "_" & field & "_"
else
image_base_name = "upload/" & zulu & "_" & zone & "_" & field & "_"
& depth & "_"
end if
image_name(0) = image_base_name & "000H" & ".png"
image_name(1) = image_base_name & "012H" & ".png"
image_name(2) = image_base_name & "024H" & ".png"
image_name(3) = image_base_name & "036H" & ".png"
image_name(4) = image_base_name & "048H" & ".png"
%>

<script language="JavaScript1.2">
<!--
var ns4=document.layers?1:0
var ie4=document.all&&navigator.userAgent.indexOf("Ope ra")==-1
var ns6=document.getElementById&&!document.all?1:0
var delay = 400;
var animeTimer;
var icon_dir = 'images/animation_buttons';
var lang = 'en';
var PreLoadedImages= new Array();

var TotalImage = 5;

var TabImagesComplete = new Array();

TabImagesComplete[0] = <=%image_name(0)%>;
TabImagesComplete[1] = <=%image_name(1)%>;
TabImagesComplete[2] = <=%image_name(2)%>;
TabImagesComplete[3] = <=%image_name(3)%>;
TabImagesComplete[4] = <=%image_name(4)%>;

function MM_callJS(jsStr) { //v2.0
return eval(jsStr);
}

//-->
</script>
<SCRIPT LANGUAGE="JavaScript" src="js/animateview.js" type="text/
javascript"> </script>
</head>

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      09-11-2007
Brendan wrote:
> I have the following asp page in which I need to generate images
> filenames from asp variables and pass these to the client side
> javascript that will animate the images. The code below does not work.
> How do I pass the filenames to the ajvascript. The code below does not
> do it and I do not understand why.
>
> TabImagesComplete[0] = <=%image_name(0)%>;
> TabImagesComplete[1] = <=%image_name(1)%>;
> TabImagesComplete[2] = <=%image_name(2)%>;
> TabImagesComplete[3] = <=%image_name(3)%>;
> TabImagesComplete[4] = <=%image_name(4)%>;
>


1. How do you know that it's not? Have you Viewed Source to verify that
the strings don't appear in the response?
2. It would probably help to delimit these strings:
TabImagesComplete[0] = '<=%image_name(0)%>';

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
 
 
 
Brendan
Guest
Posts: n/a
 
      09-11-2007
Thanks for your reply. Seems to be a problem with having asp code in
the head of the page. At least, when I delete the asp from the head,
the page loads. Dammit....

 
Reply With Quote
 
Brendan
Guest
Posts: n/a
 
      09-11-2007
On Sep 11, 1:02 pm, Brendan <(E-Mail Removed)> wrote:
> Thanks for your reply. Seems to be a problem with having asp code in
> the head of the page. At least, when I delete the asp from the head,
> the page loads. Dammit....


Oops. Missed a trailing comma.... Stewpid me.

 
Reply With Quote
 
Tim Slattery
Guest
Posts: n/a
 
      09-11-2007
Brendan <(E-Mail Removed)> wrote:


>TabImagesComplete[0] = <=%image_name(0)%>;


Shouldn't this be:

TabImagesComplete[0] = <%=image_name(0)%>;

--
Tim Slattery
MS MVP(DTS)
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://members.cox.net/slatteryt
 
Reply With Quote
 
Brendan
Guest
Posts: n/a
 
      09-11-2007
Yes. Thanks. It works now.

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      09-11-2007
Tim Slattery wrote on 11 sep 2007 in
microsoft.public.inetserver.asp.general:

> Brendan <(E-Mail Removed)> wrote:
>
>
>>TabImagesComplete[0] = <=%image_name(0)%>;

>
> Shouldn't this be:
>
> TabImagesComplete[0] = <%=image_name(0)%>;


Only if you want to assign a number.

If you want to assign a string, do:

TabImagesComplete[0] = '<%=image_name(0)%>';


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Client side script after client side validation with asp.net 2.0 Boss302 ASP .Net 0 11-21-2006 08:43 AM
Passing a value from server side to client side kimberly.walker@consultant.com ASP .Net 4 07-13-2006 09:07 AM
passing a string from the server to client side javascript =?Utf-8?B?THluZXJz?= ASP .Net 10 04-03-2006 06:13 PM
server side code access the text of <asp:label> changed by client-side javascript code? nick ASP .Net 3 12-15-2004 06:26 PM
Passing a text string from the server side to a client side function ken busse ASP .Net 2 11-24-2003 08:18 AM



Advertisments