p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 31st, 2005, 03:36 PM
Friend of Wrox
Points: 487, Level: 7
Points: 487, Level: 7 Points: 487, Level: 7 Points: 487, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Houston, TX, USA.
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old April 1st, 2005, 12:28 AM
Friend of Wrox
Points: 1,882, Level: 17
Points: 1,882, Level: 17 Points: 1,882, Level: 17 Points: 1,882, Level: 17
Activity: 7%
Activity: 7% Activity: 7% Activity: 7%
 
Join Date: May 2004
Location: India
Posts: 563
Thanks: 0
Thanked 14 Times in 14 Posts
Default

Hi,

 You cannot call server side functions from javascript, You can submit the form and then call the function.

Om Prakash
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old April 1st, 2005, 10:27 AM
Friend of Wrox
Points: 487, Level: 7
Points: 487, Level: 7 Points: 487, Level: 7 Points: 487, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Houston, TX, USA.
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!

Andraw

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old March 7th, 2006, 12:50 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old April 26th, 2006, 07:05 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old April 26th, 2006, 07:08 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to get FILE input box value in vbscript variable for validation purpose at client side.

How can I do it?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old April 26th, 2006, 09:07 PM
Friend of Wrox
Points: 5,604, Level: 31
Points: 5,604, Level: 31 Points: 5,604, Level: 31 Points: 5,604, Level: 31
Activity: 41%
Activity: 41% Activity: 41% Activity: 41%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 Posts
Send a message via AIM to mat41
Default

;;;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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old 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
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old 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
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #10 (permalink)  
Old May 8th, 2006, 07:53 PM
Friend of Wrox
Points: 5,604, Level: 31
Points: 5,604, Level: 31 Points: 5,604, Level: 31 Points: 5,604, Level: 31
Activity: 41%
Activity: 41% Activity: 41% Activity: 41%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 Posts
Send a message via AIM to mat41
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass javascript variable to xsl eruditionist XSLT 4 September 8th, 2008 09:37 AM
javascript after server side code k.manisha ASP.NET 1.0 and 1.1 Professional 1 March 12th, 2007 07:28 PM
How To Pass Javascript variable to vbscript pbcatan Classic ASP Databases 1 December 18th, 2006 08:42 AM
Pass variable to linked server query sofya SQL Server 2000 4 November 23rd, 2004 02:38 PM
sharing a server-side variable with client-side pigtail Javascript How-To 6 November 4th, 2004 02:01 AM



All times are GMT -4. The time now is 08:11 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc