■テキスト、パスワード、ファイル、テキストエリアの内容を参照、変更したい


お名前:

パスワード:

ファイル名:

ご要望:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>テキスト、パスワード、ファイル、テキストエリアの内容を参照、変更したい</title>
<script type="text/JavaScript">
<!--
function value_disp() {
alert("お名前(document.fm1.name.value) = "+document.fm1.name.value+"\n"+
"お名前のvalue初期値(document.fm1.name.defaultValue) = "+document.fm1.name.defaultValue+"\n"+
"パスワード(document.fm1.pass.value) = "+document.fm1.pass.value+"\n"+
"ファイル名(document.fm1.fname.value) = "+document.fm1.fname.value+"\n"+
"ご要望(document.fm1.demand.value) = "+document.fm1.demand.value+"\n"+
"ご要望のvalue初期値(document.fm1.demand.defaultValue) = "+document.fm1.demand.defaultValue);
}
function value_chg() {
document.fm1.name.value = "■名前のvalueを変更しました■";
document.fm1.pass.value = "password";
document.fm1.demand.value = "■入力されている文章を変更しました■";
}
// -->
</script>
</head>

<body>
<p>■テキスト、パスワード、ファイル、テキストエリアの内容を参照、変更したい</p>
<form name="fm1" action="mailto:tateda-yoshio@nifty.com" method="post" enctype="text/plain">
<p><input type="button" onclick="value_chg()" value="各エレメントのvalue変更">
<input type="button" onclick="value_disp()" value="各エレメントの内容表示"></p>
<hr>
<p>お名前:<input type="text" name="name" value="お名前をお書きください。" size="50" onfocus="this.select()"></p>
<p>パスワード:<input type="password" name="pass"></p>
<p>ファイル名:<input type="file" name="fname" value="ファイル名です。"></p>
<p>ご要望:<textarea name="demand" rows="3" cols="40" onfocus="this.select()">ご要望をお書きください。</textarea></p>
</form>

</body>
</html>


★解説★