I would like to change the text in the textbox id=”1″ when different radio buttons are focused. I thought it would work with “this.value” but somehow it dosn’t. Has someone any idea how to solve this?
Regards!
<head>
<title>Test</title>
<script type="text/javascript">
var a = function(){
if(this.value == "p"){
document.getElementById("1").value = "Question product";
}
else if(this.value== "v"){
document.getElementById("1").value = "Question contract";
}
else if(this.value== "t"){
document.getElementById("1").value = "Question technology";
}
}
</script>
</head>
<body>
<input type="radio" name="typ" value="p" onfocus="a()"/> product
<input type="radio" name="typ" value="v" onfocus="a()"/> contract
<input type="radio" name="typ" value="t" onfocus="a()"/> technology
<br />
<input type="text" value="Question" size="46" id="1"/>
</body>
</html>
Do not use focus but onclick and please use an array and give the field an ID beginning with a letter or underscore