 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP 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
|
|
|
|

March 31st, 2005, 03:36 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to pass javascript variable to server side
Hi, all,
I have a function defined in the server side(<%...%>) in asp, now I want to call the function from javascript and pass the javascript variable as argument to the server side function, is it possible??
For example:
<%
function resizeImage(fileName, width, height)
............
end function
%>
<script langage=javascript>
var fileName = "......."
answer = "<%=resizeImage(fileName , 200,200)%>"
</script>
The function must be defined in the server side. I know the above line doesn't know the variable "fileName", is there any way I can pass it to the function in the same page????? don't think about call the page itself again or submit the form, just in the same page.
andraw
|
|

April 1st, 2005, 12:28 AM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
|
|
Hi,
You cannot call server side functions from javascript, You can submit the form and then call the function.
Om Prakash
|
|

April 1st, 2005, 10:27 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks!
Andraw
|
|

March 7th, 2006, 12:50 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
Though it is not possible but, another solution is perfect to call server-side function that is
In this problem [u]you cannot pass a variable to server side function </u>but, you can pass variable value to that function and it will send result back to client on same page.
DOIT.
--Anoop K Goyal
Jaipur
|
|

April 26th, 2006, 06:05 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I want to access javascript variable in vbscript.
It can be done if javascript code is runat=server but,
if [u]I want to run this on client-side then how it will be</u>? write me.
|
|

April 26th, 2006, 06:08 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I want to get FILE input box value in vbscript variable for validation purpose at client side.
How can I do it?
|
|

April 26th, 2006, 08:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
;;;I want to access javascript variable in vbscript. It can be done if javascript code is runat=server but.
How do you do this I am intrigued?
Wind is your friend
Matt
|
|

May 2nd, 2006, 09:06 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ahhh... this response is to the original post. It looks to me that you might want to use Ajax.
I am sure you would have thought of that yourself if you had been exposed to it before now.
Essentially, Ajax allows you to call server-side functionality from within javascript.
There is lots of info on Ajax and how to do it so all you have to do is a Google search to start exploring.
Woody Z http://www.learntoprogramnow.com
|
|

May 8th, 2006, 06:28 PM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by mat41
;;;I want to access javascript variable in vbscript. It can be done if javascript code is runat=server but.
How do you do this I am intrigued?
|
I am not sure I am addressing your question... but have a look at this - It is all server side, of course.
Code:
<%@LANGUAGE="VbScript"%>
<SCRIPT LANGUAGE="JavaScript" RUNAT="Server">
var m = "I am in a JavaScript Variable"
function HelloJavaScript()
{
return "Hello World in JavaScript";
}
function printWords(words)
{
return "These words were passed in to a JavaScript function \"" + words + "\""
}
</SCRIPT>
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
function HelloVbScript
HelloVbScript="Hello World in VBScript"
end function
function passingValueToVbscriptFromJavascript(myValue)
passingValueToVbscriptFromJavascript = "We passed the words: """ & myValue & """ From JavaScript to VbScript"
end Function
</SCRIPT>
<%
' we are back in VbScript here...
Response.Write(HelloVbScript() + "<br/>")
Response.Write(HelloJavaScript() + "<br/>")
' we are calling Javascript from within VbScript
Response.Write(printWords( HelloVbScript ) + "<br/>")
' and here is a javascript variable being accessed from vbscript
Response.Write m
%>
Woody Z http://www.learntoprogramnow.com
|
|

May 8th, 2006, 06:53 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Very interesting indeed, thankyou for the in-site. After looking at your code I done some further looking pureley out of interest (I can not imagine why I would have a need for it however find it interesting) This link would add to the usefulness of this post:
http://www.webhostingtalk.com/archiv...d/91704-1.html
Wind is your friend
Matt
|
|
 |