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

135
Vistas
How do i set the value of a dropdown list to a function i have in java script

this is the javascript function that I have

function GetUserAddress() {
  var address = '<%= Session["addressmap"].ToString() %>';
  return address;
}

I want to set the value for this dropdown list below to whatever address this function returns

<select id="end">
  <option value="" >Select Value</option>
  <option value="GetUserAddress()" ></option>
</select>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Considering your address variable returns an Array, you can do something like this in plain JS to create custom options. jsfiddle DEMO : jsfiddle

    <select id="end">
      <option value="" >Select Value</option>
      
    </select>
    <script>
    (function() {
        var address = ['USA','Australia'];
        var select = document.getElementById("end");
        for (var i = 0; i < address.length; i++) {
            var option = document.createElement("option");
            option.setAttribute("value", address[i]);
            option.text = address[i];
            select.appendChild(option);
            }
    })();
    </script>

This is just to give you an idea of how you can achieve dynamic operations.

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