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

Html password field, How do you define an HTML password field? Use type ...

How do you define an HTML password field? Use type = password for the form element. This provides a minimal level of visual privacy but the text is submitted in plain text.

We want to connect our two websites shopping carts, Connect shopping carts ...

Connect shopping carts to software We want to connect our two websites shopping carts with the software of Shipwire (company distributing our products once they are sold online)

Needed a programmer experienced in wp theme, Programmer Experienced in WP T...

Programmer Experienced in WP Theme I have installed theme with bluehost. I have created the front page. Purchased Form Maker. My website has the front page designed. I want h

Data types, A value, the data assigned to a variable, may contain any sort ...

A value, the data assigned to a variable, may contain any sort of data. Though, JavaScript considers data to fall into many possible types. Based on the type of data, certain opera

Jquery animations for website help needed, Finish JQuery Animations for Web...

Finish JQuery Animations for Website I am seeking a resources in the US that can work US hours ASAP to finish a couple JQuery animations for our website. The animations are pret

Convert a non-responsive wordpress theme to responsive theme, Convert a non...

Convert a non-responsive wordpress theme to responsive Twitter Bootstrap3 My website is a none responsive wordpress theme. I want to translate this theme into responsive theme u

Web programmer need to integrate web and database, Web Programmer need to i...

Web Programmer need to integrate web and database Requirements- The primary responsibility of the intended web programmer is- 1) Choose as well as customize website templa

Does udp provide any security feature for mip, Question: a) An applica...

Question: a) An application sends a message which is 3400 bytes long. It sends the data as one UDP datagram. The message is then transferred from a sender to a receiver over t

We need to create a localization tool to organise multiple, We need to crea...

We need to create a localization tool to organise multiple planning The web based tool must do the follow Import excel sheet where you have a list of n events with at least t

Want html5 and js for video capture from camera, Want HTML5 and js for vide...

Want HTML5 and js for video capture from camera as well as upload to server HTML5/js solution to permit users to capture a video clip (with audio), give the clip a name as well

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