Som 10/09-2006 22:49:08 sammen med 10/09-2006 22:56:36
og så en betingelse på at du kun er a der skal nulstilles
når value i b ændres - altså så længe b er forskellig fra
ingenting / standard value - skal a nulstilles:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Ingen titel</title>
<script type="text/javascript">
function chkinputab(tn,tn2){
if(tn.defaultValue!=tn.value){
tn.form[tn2].value=tn.form[tn2].defaultValue;
}
}
</script>
</head><body>
<form>
a: <input type="text" name="a" onkeyup="chkinputab(this.form.b,'a');" onchange="chkinputab(this.form.b,'a');"><br>
b: <input type="text" name="b" onkeyup="chkinputab(this,'a');" onchange="chkinputab(this,'a');">
</form>
</body></html>
... Hvis a kun skal nulstilles når man piller i b - og ikke når man retter inde i selve a skal den se sådan her ud:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Ingen titel</title>
<script type="text/javascript">
function chkinputab(tn,tn2){
if(tn.defaultValue!=tn.value){
tn.form[tn2].value=tn.form[tn2].defaultValue;
}
}
</script>
</head><body>
<form>
a: <input type="text" name="a"><br>
b: <input type="text" name="b" onkeyup="chkinputab(this,'a');" onchange="chkinputab(this,'a');">
</form>
</body></html>
- Hvis det modsatte felt af det man piller i skal nulstilles så er det
10/09-2006 22:49:08 sammen med 10/09-2006 22:56:36:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Ingen titel</title>
<script type="text/javascript">
function chkinputab(tn,tn2){
if(tn.defaultValue!=tn.value){
tn.form[tn2].value=tn.form[tn2].defaultValue;
}
}
</script>
</head><body>
<form>
a: <input type="text" name="a" onkeyup="chkinputab(this,'b');" onchange="chkinputab(this,'b');"><br>
b: <input type="text" name="b" onkeyup="chkinputab(this,'a');" onchange="chkinputab(this,'a');">
</form>
</body></html>