|
|
 |
| 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |
|

March 31st, 2005, 03:36 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Location: Houston, TX, USA.
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
Location: India
Posts: 563
Thanks: 0
Thanked 14 Times in 14 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
Location: Houston, TX, USA.
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks!
Andraw
|

March 7th, 2006, 12:50 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
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, 07:05 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
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, 07:08 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
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, 09:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 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, 10:06 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: San Diego, CA, USA.
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, 07:28 PM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: San Diego, CA, USA.
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, 07:53 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |