Hoi
Hoe kan ik een input veld maken met een value die verdwijnt wanneer men erop klikt om het input veld in te vullen? (doorgaans wordt de value dan in het lichtgrijs weer gegeven)
BvD
4.090 views
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Input field tricks</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function init () {
var _veld1 = document.getElementById ('veld1');
_veld1.onfocus = function () {
return handle_focus (this);
}
_veld1.onblur = function () {
return handle_blur (this);
}
}
function handle_focus (obj) {
if (obj.value == 'charge nr.') {
obj.value = '';
obj.className = 'zwart';
}
}
function handle_blur (obj) {
if (obj.value == '') {
obj.value = 'charge nr.';
obj.className = 'grijs';
}
}
window.onload = init;
</script>
<style type="text/css">
input.grijs {
color: #999;
background: #fff;
}
input.zwart {
color: #000;
background: #fff;
}
</style>
</head>
<body>
<form method="post" action="#">
<p>
<label for="veld1">veld 1:</label>
<input id="veld1" name="veld1" type="text" class="grijs" value="charge nr.">
<input type="submit" value="go">
</p>
</form>
</body>
</html>
<script type="text/javascript">
function init () {
var _veld1 = document.getElementById ('veld1');
_veld1.onfocus = function () {
return handle_focus (this);
}
_veld1.onblur = function () {
return handle_blur (this);
}
MaakKalender()
}