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

199
Views
Pass dropdown value to onclick method

I have a dropdown and link. I'm trying to pass selected dropdown value to onclick.

    <div>
        <select class="browser-default custom-select" id="venflows">
            <option value="marcus">marcus</option>
            <option value="bruno">bruno</option>
            <option value="jadon">jadon</option>
            {% endfor %}
        </select>
    </div>



        <div>
            <a onclick="window.location.href = 'download/dropdown_selected_value_here'"></a>
        </div>

Here i'm trying to pass selected dropdown value to click. Ex: if marcus is selected when onclick it should be like this

        <div>
            <a onclick="window.location.href = 'download/marcus'"></a>
        </div>

Ex: if bruno is selected when onclick it should be like this

        <div>
            <a onclick="window.location.href = 'download/bruno '"></a>
        </div>
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

To answer your question as posed

<a onclick="window.location.href = 'download/'+document.getElementById('venflows').value"></a>

But I recommend an eventListener

document.getElementById("link").addEventListener("click", function() {
  const url = `download/${document.getElementById("venflows").value}`
  console.log(url); // for testing
  this.href = url;
})
<div>
  <select class="browser-default custom-select" id="venflows">
    <option value="marcus">marcus</option>
    <option value="bruno">bruno</option>
    <option value="jadon">jadon</option>
  </select>
</div>
<div>
  <a href="" id="link">GO</a>
</div>

about 4 years ago · Santiago Gelvez Report

0

If you want onclick event then you can try this

       <select class="browser-default custom-select" id="venflows" onclick="customFunction(this)">
            <option value="marcus">marcus</option>
            <option value="bruno">bruno</option>
            <option value="jadon">jadon</option>
            {% endfor %}
        </select>
          
       <div>
            <a onclick="window.location.href = 'download/dropdown_selected_value_here'" id="url_nav"></a>
        </div>
     
        function customFunction(curObj){
            document.getElementById("url_nav").onclick = "window.location.href = 'download/'+curObj.value+"
        }
about 4 years ago · Santiago Gelvez 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!