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

Explain features of php, Question: (a) (i) Name four features of PHP t...

Question: (a) (i) Name four features of PHP that makes it an appropriate choice as a Web programming language. (ii) List advantages while using PHP scripting language.

Explain how to submit form without a submit button, Explain how to submit f...

Explain how to submit form without a submit button. We can achieve above task by using JavaScript code linked to an event trigger of any form field and call document.form.submi

I need to optimize my wordpress website, I need to optimize my wordpress we...

I need to optimize my wordpress website My website is very sluggish. Will you be capable to optimize. I have AWS S3 as well as CloudFront CDN to optimize the delivery. I want so

We need a wordpress expert for assistance, We need a Wordpress expert for a...

We need a Wordpress expert for assistance We have bring a wordpress site that is too slow. Our programmer says it's for the reason that of the CivicRM program being slow- We

Looking for a developer to build a ratings or review website, Looking for a...

Looking for a Developer to Build a Ratings/Review Website The impartial is to create a professor/teacher rating website that offers more transparency then what is currently avai

Overview of dreamweaver, Let us begin with a brief overview of Dreamweaver ...

Let us begin with a brief overview of Dreamweaver work area. If you haven't launched Dreamweaver already, double-click on the Dreamweaver icon on your desktop to do so. While yo

I need help for presentation website in progressive design, Presentation we...

Presentation website in progressive design We want a Presentation website in a progressive design with easy CMS. The website will represent a carpenter as well as contain the fo

Web developer with cms applications, Web Developer a) Intermediate to ad...

Web Developer a) Intermediate to advanced skill level with WordPress (Essential) and some experience working with leading CMS applications. b) Strong knowledge of Classic ASP

Dial-up connection, O ne of the commonest ways of connection to Internet is...

O ne of the commonest ways of connection to Internet is by dial up connection via a modem & a telephone line. Using these you can link to a host machine on the Internet. Once linke

We are looking for concrete 5 developer, We are looking for Concrete 5 Deve...

We are looking for Concrete 5 Developer We are seeking someone to partner with your support our small business clients with developing websites using a CMS platform, preferably

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