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

257
Views
How i can get the value string from a drop down list

please how i can get correctly the value from the drop down list, i have used django-widget-tweaks library .

this is the code of the field dropdown list that i want to get the value string from it:

<p >{{ form.category_column.label_tag }}</p>
<p id="category_column_id">{% render_field form.category_column  autocomplete="off" hx-get="/sizescolumn/" hx-target="#id_sizes_column" %}</p>

I have tried to got the value using javascript by this line of code :

var select = document.getElementById('category_column_id').value;

PS: I want to get the value string of this field(dropdown list) to compare it with another value string.

---->but it doesn't work. thanks in advance.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

To get the string value of the selected item user .innerHTML instead of .value

var select = document.getElementById("yourId").innerHTML;
about 4 years ago · Juan Pablo Isaza Report

0

You have added the id attribute id="category_column_id" to the <p> tag.

Particular id attributes should only be used once on a page as Ids are unique (as opposed to classes). If your select attribute has the same id, ie, 'category_column_id' then the <p> tag will probably be found first and used by your javascript. A <p> tag doesn't have a value the way a select column does, so your javascript is not returning anything.

First, doublecheck on your page what your select element ID is, and then use your javascript to assess the value. There's nothing particularly wrong with your javascript itself in modern browsers so long as you have the correct id and there is only one of that particular id.

about 4 years ago · Juan Pablo Isaza Report

0

Thanks for everyone here Fixed like this:

        var select = $('#id_category_column').find(":selected").text();
       

I hope it will help someone in future.

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!