Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda