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

Magento community m2e pro integration with rekuten, Magento Community M2E P...

Magento Community M2E Pro integration with Rekuten, Ebay, Amazon We are seeking an experienced individual that will integrate our Magento (1.6.1.1) with other market places- Ama

We need a php developer for website, SanaSana Website Ecommerce website ...

SanaSana Website Ecommerce website using MySQL, Magento, PHP. There is several customization required for themes. Data has by now been procured. Desired Skills are MySQL Admi

Create an html document and java applets, For this project, you are requir...

For this project, you are required to design and create an HTML document (also referred to as a "Web page"), in which certain basic HTML elements are incorporated. Your HTML docume

Want a facebook app designed for a social media, Facebook App Developer ...

Facebook App Developer I want a Facebook app designed for a social media contest where users can upload a picture and comment share it with friends and other users can like it a

Html5 based txt/csv data file charter, HTML5 Based TXT/CSV Data File Charte...

HTML5 Based TXT/CSV Data File Charter In search of a web developer to create a HTML5/JavaScript based web application to import tab delimited or comma separated information from

Want wordpress installed on a website, Want wordpress installed on a websit...

Want wordpress installed on a website I have a fresh website that was created in HTML, however I need wordpress CMS installed so that I can make changes and add content easily.

Looking for web programmer for start-up, Looking for web programmer for sta...

Looking for web programmer for start-up (B2C platform plus app, similar Airbnb style) We just started besides need a web programmer who is intended to code only. Desired Skil

Authenticate the name and password, Keep a list of allowed reporters and th...

Keep a list of allowed reporters and their passwords in a database table Authentication .  Define and populate the table beforehand manually using the phpMyAdmin interface to MySQ

You have to sculp a web site, You have to Sculp A web site Project Descr...

You have to Sculp A web site Project Description: I have a web site that has to be sculped and have a protection with watermart, we require to sculp the whole web site and re

Send an email via php, Only perform this function if the email address subm...

Only perform this function if the email address submitted is valid and its limit has not been exceeded, and of course the original reporter name and password Authentication has bee

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