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

113
Views
Accessing radio button value outside the function in javascript

I need the value of the radio button outside the function.

In the following code, the variable value returns a new value every time the radio button is pressed, however, the date value does not change.

    var date_value=2;        
    var $radios = $('input[name=daterange]').change(function () {
    var value = $radios.filter(':checked').val();
    console.log('value'+value);
    date_value = value;
    });
    console.log('date value'+date_value);

HTML

       <div id="dates" name="daterange">

      <p>
        <input type="radio" id="d1" name="daterange" value='2'/> 
        <label for="d1">24 hours</label>
        <br> 
        <input type="radio" id="d3" name="daterange" value='7'/> 
        <label for="d3">7 days</label>
        <br> 
        <input type="radio" id="d4" name="daterange" value='30'/> 
        <label for="d4">1 month</label>
</div>
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!