August 1999
Intermediate to advanced
1488 pages
72h 53m
English
return
The return keyword will exit the existing function and return a value.
Listing 6.227 shows an example of using the return statement to return the value of the processing from the function.
<html>
<body>
<script language="JavaScript">
<!–– Hide
function getValue(){
var myValue = 4*3;
return myValue;
}
function fill(){
var x = getValue();
document.form1.tmp.value = x;
}
// End Hide ––>
</script>
<form name="form1">
Value: <input type="text" Name="tmp" Size=5>
<br>
<br>
<input type="button" name="get" value="Get Returned Value" onClick='fill()'>
<br>
<br>
</form>
</body>
</html>
|
Read now
Unlock full access