Calling functions

This is a discussion on "Calling functions" within the Classic ASP section. This forum, and the thread "Calling functions are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 7th, 2007, 10:21
Junior Member
Join Date: Aug 2007
Location: UK
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Calling functions

Hi I am fairly new to ASP so don't laugh too loud. Firstly, how do I call functions in ASP and is it possible to call a javascript from ASP.

Regards
Rob
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 7th, 2007, 10:45
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Calling functions

You call a function like this:
PHP: Select all

void DoNothing() { // this is the function declaration
  // do a bit of nothing
}
// call it like so
DoNothing(); 
If the function requires parameters then they go between the parentheses:
PHP: Select all

void AddTwoNumbers(int num1int num2) { // this function requires 2 integers
  // add the numbers
  
int result num1 num2;
}
// call it like so
AddTwoNumbers(24); 
Then, if the function also returns a value you can store it in a variable like so:
PHP: Select all

int GetSum(int num1int num2) { // this function requires 2 integers
  
int result num1 num2// add the numbers
  
return result// and return the result
 
}
 
// call it like so and store the returned value
int function_result AddTwoNumbers(24);
// now 'function_result' equals 6 
Hope that makes some sense.

Your question was a bit vague. If you could be a bit more specific or post some code, it would help us help you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 7th, 2007, 11:30
Junior Member
Join Date: Aug 2007
Location: UK
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Calling functions

Hi thanks for that. I fully understand the javascript you posted but wondered if a javascript function can be called by using VB script. The reason I ask is that I am running a small access database on a site and as far as I am aware you can't make a connection via javascript, (or can you?), so I am using ASP VB script to access the database and javascript to do other stuff. Or am I asking too much?

Cheers
Rob
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Aug 7th, 2007, 12:55
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Calling functions

Javascript is client-side. ASP is server-side.

That means that ASP generates HTML and Javascript and sends it to the browser. Javascript runs on the client browser and can't access a server. The two languages can't "run" together because one lives on a web server and the other lives in browsers, so to speak.

I think you could load stuff from a databank using Ajax, but I'm not an Ajax person at all.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Aug 7th, 2007, 14:44
Junior Member
Join Date: Aug 2007
Location: UK
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Calling functions

Thanks, that makes a lot of sense now. I should have realised that.
Cheers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Aug 7th, 2007, 14:54
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Calling functions

I can understand you. It took me a while to grasp the concept of client / server side languages. When I was learning PHP I kept getting confused about what I could and couldn't do because I didn't realize that HTML is client side and PHP generates HTML on the server and sends the output to the browser....

Anyway, you're welcome and good luck!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
asp

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
calling functions in a function fatsurfer PHP Forum 1 Jun 12th, 2008 21:53
Calling functions with variable? CloudedVision JavaScript Forum 1 Apr 18th, 2008 08:44
Functions? Jack Franklin PHP Forum 10 Feb 3rd, 2008 16:49
Calling functions between frames apparentlyso JavaScript Forum 0 Oct 18th, 2006 21:07
Calling functions in mail message Andy K PHP Forum 2 Aug 24th, 2005 18:47


All times are GMT. The time now is 13:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42