Returning a value, PHP Web Programming

Assignment Help:

Another function of a function is to return a value. Imagine we have the following function:

<HTML>

<HEAD>

<TITLE>IGNOU </TITLE>

<SCRIPT Language = "JavaScript">

function calculate(a,b,c)

{

d = (a+b) * c;

return d;

}

</SCRIPT>

</HEAD>

<BODY>

<SCRIPT Language = "JavaScript">

var x = calculate(4,5,9);

var y = calculate((x/3),3,5);

alert('calculate(4,5,9) = ' +x + ' and ' + ' calculate((x/3),3,5) = ' + y);

</SCRIPT>

</BODY>

</HTML>

 

322_Returning a value.png

Figure:  Using a Function that Returns a Value

The function illustrated in Figure calculates a number from the numbers you pass to it. While this is done it returns the result of the calculation. The function passes the result back to the function which called it. While the function executes return statement, control goes back to the calling program without executing any more code in function, if there is any.

The calling of the function is done via the following two statements in the figure:

var x = calculate(4,5,9);

var y = calculate((x/3),3,5);

This means that you have declared variable x and are telling JavaScript to execute calculate ( ) along the arguments 4, 5 & 9 and to put the returned value (81) in x. After that you declare a variable y and execute calculate ( ) again. The first argument is x/3, which means 81/3 = 27, thus y becomes 150.Certainly you can also return strings or even Boolean values (true or false). While using JavaScript in forms, you can write a function which returns either false or true and therefore tells the browser whether to submit form or not.


Related Discussions:- Returning a value

We are looking for a web developer to edit website and apps, We are looking...

We are looking for a Web Developer to edit website and apps Ok as well as the features what apps and site must have now is (1. Voice post 2. 3d blog 3. All members will have poi

We need help for gmail mail merge script, We need help for Gmail Mail Merge...

We need help for Gmail Mail Merge Script We need a script written that will work with a Gmail account in a Google business account. I have installed as well as run many of the a

Bowline website for it security company, Bowline Website I do like to ha...

Bowline Website I do like to have a website created for my company. It is an IT Security Company. The target spectators is in Africa. I am seeking at about 25 pages to be develo

History object, This is a predefined JavaScript object that is accessible b...

This is a predefined JavaScript object that is accessible by the history property of a window object. The window. history property is array of URL strings that reflect the entries

What are the differences between http and https, Question 1: Describe i...

Question 1: Describe in detail how public key and private key cryptography are used to provide secure access from a browser to a Web server over the Internet so that a commerc

Need a cake php developer with good skillet, Require to get some Changes do...

Require to get some Changes done on a Cake PHP Website Project Description: Need a Cake PHP Developer with good skillet and decent command over the Framework. The develope

Need help to create amazon affiliat store, Amazon Affiliat Store I need ...

Amazon Affiliat Store I need your services to build me an Amazon Affiliate Webstore (for Health as well as Personal Care Products). Script must import inventory from amazon. Int

I want help for booking travel site, Booking Travel Site The flow of the...

Booking Travel Site The flow of the website must have entirely of the functionality of Orbitz.com using GDS integration directly with Sabre. The complete concept of the website

Http and world wide web, One of the most commonly utilized services on the ...

One of the most commonly utilized services on the Internet is the World Wide Web (WWW). The application protocol which makes the web work is Hypertext Transfer Protocol or HTTP. Do

We need drupal updates, We need Drupal Updates We have 6 websites built ...

We need Drupal Updates We have 6 websites built on the Drupal platform that essentially updating from v.6 to v.7. We need a Drupal developer to help us update as well as test ea

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd