<script type="text/javascript">
window.onload = function() {
var forma = document.forma,
input = forma.input, i = input.length,
array = ['query1', 'query2', 'query3'];
while(i--) {
input[i].onchange = function(i) {
return function() {
forma.text.value = array[i];
};
}(i);
}
};
</script>
<form name="forma" action="" method="post">
<input type="radio" name="input" />Запрос 1
<input type="radio" name="input" />Запрос 2
<input type="radio" name="input" />Запрос 3<br />
<textarea rows="6" cols="26" name="text" /></textarea>
</form>
или в такой нотации:
<script type="text/javascript">
window.onload = function() {
var forma = document.forma,
input = forma.input,i = input.length,
array = {
value1 : 'query1',
value2 : 'query2',
value3 : 'query3'
};
while(i--) {
input[i].onchange = function(i) {
return function() {
forma.text.value = array[this.value];
};
}(i);
}
};
</script>
<form name="forma" action="" method="post">
<input type="radio" name="input" value="value1" />Запрос 1
<input type="radio" name="input" value="value2" />Запрос 2
<input type="radio" name="input" value="value3" />Запрос 3<br />
<textarea rows="6" cols="26" name="text"></textarea>
</form>