Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: "undefined" error after writing VBSCRIPT output inside JAVASCRIPT file


Message #1 by "Thomas" <p2pwrox@k...> on Wed, 27 Nov 2002 23:31:00
	I can see there's a big confusion in your mind.

1) What you referred to as VBScript code are included between <% and 
%>,
right?  These codes are executed in the server.
2) Response.write is executed by the server, while document.write is
executed by the client.  Don't mix them up.
3) Changing .js to .asp shouldn't do what you expected because, for 
example,
document.write won't be executed by ASP.
4) I don't know what those "offbackcolor" are, but they're probably not
standard client-side stuff.

	In conclusion, make a pure client-side HTML file, check that it
works properly before adding server-side stuff.

	Good luck

> -----Message d'origine-----
> De : Thomas [mailto:p2pwrox@k...]
> Envoy=C3=A9 : jeudi 28 novembre 2002 00:31
> =C3=80 : javascript
> Objet : [javascript] "undefined" error after writing VBSCRIPT output
> inside JAVASCRIPT file
>
>
> I have a database-driven ASP site, and am also trying to use a nice
> javascript for my navigation. But I want the javascript file
> to obtain the
> current list of links from a separate VB script I've written.
>
> My VB script outputs all of the links and menu options,
> formatted EXACTLY
> as the existing entries in the JS file (example code below),
> and I am able
> to write the output anywhere (using either VB response.write or JS
> document.write) - EXCEPT inside the javascript file used for the
> navigation.
>
> If I copy the outputted text from my VB script manully into the JS
> navigation file, everything displays just fine (so I'm pretty sure my 

> output formatting isn't wrong). But my attempts to get the
> javascript file
> to dynamically write the navigation using either response or
> document.write has failed so far (and just gives an
> "undefined" message).
>
> More details: I changed the .JS file's extension to .ASP so I
> can write
> variables and other code from various VB scripts. This JS
> file is a pretty
> complicated javascript that takes a whole line of stuff (for
> each link)
> and then creates a navigation menu with cool mouseover and highlight
> tricks.
>
> So here's my question: How can I write VB output to the middle of a
> javascript file?
>
> PS: Here's some example code, the output from my VB script
> used by the JS
> script to create each menu option.
>
> ,"<b><u>Articles</u></b><br>Articles go here","/articles =09
> 	offbackcolor=3D8796CD;	onbordercolor=3DE8E8E8;
> 	offbordercolor=3D8796CD;",,,0
> ,"<b><u>Contact Us</u></b><br>Contact Us or die","/contact =09
> 	offbackcolor=3D8796CD;	onbordercolor=3DE8E8E8;
> 	offbordercolor=3D8796CD;",,,0
> ,"<b><u>Tools & Calculators</u></b><br>Tools & Calculators for you to 

> use","/tools 		offbackcolor=3D8796CD;	onbordercolor=3DE8E8E8;
> 	offbordercolor=3D8796CD;",,,0
>
> PSS: Here's the VBscript
>
> <%
>
> public writeSideNav
> redim mainNav(countLinks)
> 	linkLoop =3D 0
> 	Do While linkLoop < countLinks
> 		if currLang =3D "EN" then
> 			sidenav_name	=3D server.htmlencode(RsSide
> ("navigation_name_EN"))
> 			sidenav_desc	=3D RsSide
> ("navigation_description_EN")
> 		else
> 			sidenav_name	=3D server.htmlencode(RsSide
> ("navigation_name_ES"))
> 			sidenav_desc	=3D RsSide
> ("navigation_description_ES")
> 		end if
> 				if sidenav_desc <> "" then
> 					sidenav_desc =3D "<br>" &
> sidenav_desc
> 				end if
> 		sidenav_path 		=3D RsSide("folder_location")
> 	mainNav(linkLoop) =3D ((",""<b><u>" & sidenav_name & "</u></b>" &
> sidenav_desc & """,""" & sidenav_path & " =09
> 	offbackcolor=3D8796CD;	onbordercolor=3DE8E8E8;
> 	offbordercolor=3D8796CD;"",,,0"))
>     mainNav(linkLoop) =3D replace(mainNav(linkLoop), """" ,
> chr(34)) & VBCrLf
> 	writeSideNav =3D writeSideNav & mainNav(linkLoop)
> 	RsSide.MoveNext
> 	linkLoop =3D linkLoop + 1
> 	Loop
> %>
>
> PSSS: And this is the response.write line I'm trying to use
> in the middle
> of the JS script:
>
> <%=3DwriteSideNav%>
>

  Return to Index