JSFiddle - React, Tailwind, and code Playground
HTML
<input type="radio" id="1" name="radio" value="one_method" aria-required="true" onClick="selected(this);" checked >
<input type="radio" id="2" name="radio" value="two_method" aria-required="true" onClick="selected(this);" >
<form id="one" method="GET" action="https://yandex.ru/search/?" target="_blank">
<input type="hidden" name="text">
</form>
<form id="two" method="GET" action="https://yandex.ru/search/?" target="_blank">
<input type="hidden" name="text">
</form>
<input type="button" value="Отправить" id="button-confirm" onClick="send()" class="button">
<div id="buy_info"></div>
JavaScript
window.selected = function(a) {
var label = a.value;
if (label=="one_method") {
document.getElementById("one").style.display='block';
document.getElementById('buy_info').innerHTML = "<br>текст 1"
} else {
document.getElementById("one").style.display='none';
}
var label = a.value;
if (label=="two_method") {
document.getElementById("two").style.display='block';
document.getElementById('buy_info').innerHTML = "<br>текст 2"
} else {
document.getElementById("two").style.display='none';
}
}
window.send = function() {
var method = document.querySelector("[name='radio']:checked").value;
console.log(method)
if (method=="one_method") {
document.getElementById('one').text.value = 'Первое слово';
document.getElementById('one').submit();
}
if (method=="two_method") {
document.getElementById('two').text.value = 'Второе слово';
document.getElementById("two").submit();
}
}