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 need help in site coding, We need help in Site coding I have set up a...

We need help in Site coding I have set up a marquee using a jquery plugin. a) I want to duplicate that marquee action across multiple sites using iframe or some such so that

I want wp estore theme experienced developer, WP Estore Theme Experienced D...

WP Estore Theme Experienced Developer Required Keep work on wordpress estore theme website required. Should have previous proven experience with wp estore theme. Probabili

What is php, What is PHP? PHP: Hypertext Pre-processor is open source s...

What is PHP? PHP: Hypertext Pre-processor is open source server-side scripting language which is widely used for web development. PHP scripts are executed on server. PHP allows

Website graphic design and cakephp features, Website Graphic Design and Cak...

Website Graphic Design and CakePhP Features Project Description: Installation of a number of small features and changes on Cake PhP site, as well as changing the graphics of

Selecting columns in mysql by by keying in a number, How do I select lets s...

How do I select lets say 2columns eg(Name and Payment plan)when I type in a a telephone number like 665528 to get the one row corresponding to the number I have typed?

We need help to create website and app design, We need help to create Websi...

We need help to create Website and App Design Website is internet as well as app based. Customers register accounts with email as well as zip code Free website where custo

Web store configuration, I have a webstore offered on the big commerce plat...

I have a webstore offered on the big commerce platform. I would like to move over to the deconetwork platform. I started working on it, and could do it, but. If the copy will be do

I need a wordpress expert, I Need a wordpress expert I am observing to e...

I Need a wordpress expert I am observing to establish a long term relationship with a WordPress expert. This is the first project which will have to be a basic theme website fro

Web master needed for word press as well as amember, Web Master needed for ...

Web Master needed for Word Press as well as aMember Mainly as a webmaster familiar with aMember as well as WordPress As well for web design and development. Marketing savv

Need social networking site in php, Social Networking Site in PHP I have...

Social Networking Site in PHP I have a project that is in want a of a great php coder for a social networking site. Please have very good ratings to bid. Please don't bid if you

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