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

225
Views
Radio Input onchange display label innerText in textbox
 <div class="top">
      <label for="locationName">Location:</label>
      <input type="text" class="locationName" id="locationName" maxlength="20" readonly>
 </div>
 <li>
      <input type="radio" id="selected_location_ac" name="selected_location" value="ATLANTIC_CITY" onchange="findSelection('selected_location')">
      <label for="selected_location_ac">Atlantic City</label>
 </li>
 <li>
      <input type="radio" id="selected_location_ac" name="selected_location" value="LAS_VEGAS" onchange="findSelection('selected_location')">
      <label for="selected_location_ac">LAS Vegas</label>
 </li>

JavaScript

function findSelection(rad_name) {
    const locationName = document.querySelector("#locationName");
    let rad_val = document.querySelector('input[name=' + rad_name + ']:checked');
    locationName.value = (rad_val ? rad_val.value : "")
    return (rad_val ? rad_val.value : "");
}

I am trying to get the label value displayed in the input text box.

The person will click a radio button and then the input textbox will display their selection. I don't want it to show the radio button value since it maybe difficult to understand what it means.

about 4 years ago · Juan Pablo Isaza
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!