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

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

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 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!