return

種類命令
書式 return 戻り値
解説
関数からの戻り値を指定します。複数の戻り値を指定したい場合にはreturn ["Ab",12,"OK"]のように配列を利用します。
サンプルコード
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<style type="text/css"><!--
body { margin:0px; }
form { position:absolute; top:10;left:10px; }
--></style>
<script type="text/javascript"><!--
function calc(a,b)
{
return a + b;
}
window.onload = function()
{
document.getElementById("txtField").value = calc(2,3);
}
// --></script>
</head>
<body>
<img src="Default.png">
<form>
<input type="text" id="txtField" size=40"><br>
</form>
</body>
</html>
実際のスクリプトをダウンロード