Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
How to save the input from a radio input in html/js

Hello I need your help to find a way to save my radio input and print it to the screen so I know that it is saved. I have this HTML:

 if (document.getElementById('a1').checked) {
            rate_value1 = document.getElementById('a1').value;
            document.writeln(rate_value1); 
        }
        if (document.getElementById('a2').checked) {
            rate_value2 = document.getElementById('a2').value;
            document.writeln(rate_value2); 
        }
        if (document.getElementById('a3').checked) {
            rate_value3 = document.getElementById('a3').value;
            document.writeln(rate_value3); 
        }
        if (document.getElementById('a4').checked) {
            rate_value4 = document.getElementById('a4').value;
            document.writeln(rate_value4); 
        }
        if (document.getElementById('a5').checked) {
            rate_value5 = document.getElementById('a5').value;
            document.writeln(rate_value5); 
        }
 <div class='input-form' id="div1">
        <h4 id="myText" contenteditable="true">Customize</h4>
        <input type="radio" name="rating" value="5" id="a5" ><label for="5">5</label>
        <input type="radio" name="rating" value="4" id="a4" ><label for="4">4</label>
        <input type="radio" name="rating" value="3" id="a3" ><label for="3">3</label>
        <input type="radio" name="rating" value="2" id="a2" ><label for="2">2</label>
        <input type="radio" name="rating" value="1" id="a1" ><label for="1">1</label>
    </div>
    <button type='button' id='but_add' value='Add new'>Add Rating Nums</button>



   

Thank you for your time

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try creating another element above your <div> and target it whenever you click a radio button.

<p id="details"></p>

<div>
<input type="radio" name="rating" value="5" id="a5" Onclick="display(this.value)" ><label >5</label>
</div>

In your js:

<script>

function display(x){

    document.getElementById('details').innerHTML = x;

}

</script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda