473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Passing VB to javascript

I have seen a couple of web sites that detail how to do this, but seem to be
overlooking the obvious.... I have the following code and have tried
variations to get it working;
<!--#INCLUDE FILE="CommonFunctions.inc"-->
<%
'following is vb script....
if not MyFunction(check_field) then 'This function is in the
include
DisplayError("this failed")
else
ContinueProcess 'This sub routine is
in the include
end if

sub DisplayError(iErr)
%>
<SCRIPT language="javascript">
alert( <%= iErr %>);
history.go(-1);
</SCRIPT>
<%
end sub

%>

I want to pass different messages to the displayerror function, but just
can't seem to make it work... Any ideas?
Jul 19 '05 #1
1 1198
You're going to have to think about it slightly differently. The main
reason is you think all of this script interacts, when in fact, first the
ASP runs, then the client-side script runs. Let's look at it this way:

<%
sub showError(iErr)
response.write "<script>" & vbCrLf & _
"alert('" & replace(iErr,"'","\'") & "');" & _
"history.go(-1);" & vbCrLf & _
"</script>"
response.end
end sub

' play with making something true
' and somethingElse true

something = false
somethingElse = false

if something then
showError "this failed"
end if

if somethingElse then
showError "that failed"
end if
%>

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Ruskin" <ru******@nospam.xtra.com> wrote in message
news:TC******************@news.xtra.co.nz...
I have seen a couple of web sites that detail how to do this, but seem to
be
overlooking the obvious.... I have the following code and have tried
variations to get it working;
<!--#INCLUDE FILE="CommonFunctions.inc"-->
<%
'following is vb script....
if not MyFunction(check_field) then 'This function is in the
include
DisplayError("this failed")
else
ContinueProcess 'This sub routine is
in the include
end if

sub DisplayError(iErr)
%>
<SCRIPT language="javascript">
alert( <%= iErr %>);
history.go(-1);
</SCRIPT>
<%
end sub

%>

I want to pass different messages to the displayerror function, but just
can't seem to make it work... Any ideas?

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raju V.K | last post by:
can I use javascript and PHP in the following manner to create a pop-up window: <--- in <head> </head> <script language=javascript> function popup(folder1, file1) {...
1
by: Patrice | last post by:
Hi, I'm trying to use a javascript function passing a vb variable. I don't understand why it doesn't work. Can someone help me? Thanks in advance. Here is my javascript function used to...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
5
by: Steve | last post by:
Hi, I currently have a problem passing a variable value from one page to another. Once a form submit button is pressed java pops up a window and displays some information. The problem being is...
1
by: Eric Capps | last post by:
This may be more of a Java question, but I feel that JavaScript experts may be more qualified to help me find a solution. In short: is it possible to call a Java method from JavaScript, passing...
4
by: Nathan Sokalski | last post by:
I am a beginner with AJAX, and have managed to learn how to use it when passing single parameters, but I want to return more than one value to the client-side JavaScript function that displays it....
5
by: moni | last post by:
Hi.. I am trying to use javascript for google maps display. If I call the javascript function from my aspx file I use: <input type="text" id="addresstext" value="Huntington Avenue,...
6
by: haijdp | last post by:
Hi, I am using the following javascript method inside a js file. function createDivRow(label,text) { var formedTd = '<tr><td>' + label + '</td><td> <a href="#"...
5
by: aelred | last post by:
I have a web page where a member can open up a chat window (child window) with another member. - From there the member can also navigate to other web pages. - From other pages in the site, they...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.