指定したフィールドの内容を読み出す

書式

element.getValue()

element : フォームのエレメント

説明

指定したフィールドの内容を読み出すにはgetValue()を使います。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript"><!--
function checkValue() {
alert("num1 : "+$("num1").getValue());
}
// --></script>
</head>
<body>
<h1>フィールドの内容/値を読み出す</h1>
<form id="eForm">
番号(1):<input type="text" id="num1" value="4649"><br>
番号(2):<input type="text" id="num2" value="5963"><br>
<input type="button" value="値を読み出す" onClick="checkValue()">
</form>
</body>
</html>