Nessa página HTML eu defini alguns itens
/**
* Botão Submit
*/
document.getElementById("btnSubmit").onclick = function() {
var radios = document.getElementsByName("band-rock");
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
alert("Escolheu: " + radios[i].value);
//var nome = +radios[i].value.InnerHTML;
//console.log("Escolheu: " + radios[i].value);
}
}
};
/**
* Botão Load
*/
document.getElementById("btnLoad").onclick = function() {
var radios = document.getElementsByName("band-rock");
for (var i = 0; i < radios.length; i++) {
if (radios[i].value === "The Beatles") {
radios[i].checked = true;
}
}
};
<form action="form-action.php" method="post">
<p>
<input type="radio" name="band-rock" value="Beatles" />The Beatles
<input type="radio" name="band-rock" value="Led Zeppelin" /> Led Zeppelin
<input type="radio" name="band-rock" value="Pink Floyd" />Pink Floyd
<input type="radio" name="band-rock" value="Black Sabbath" />Black Sabbath
</p>
<p>
<input type="button" id="btnSubmit" value="Submit me!" />
<input type="button" id="btnLoad" value="Load!" />
</p>
<p>
<input type="text" id="texto" name="band-rock" value="" disabled/>
</p>
</form>
Como faço para que ao invés de retornar no alert eu retorne no campo input???