Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!