Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:46:52+00:00 2026-06-05T06:46:52+00:00

I am trying to set the selected value in a dropdownlist using jquery, I

  • 0

I am trying to set the selected value in a dropdownlist using jquery, I have this:

 $('.option_vehiculo', '#form_login').each(function() 
{
    if (this.id == tipo_vehiculo_def)
    {
         this.value = "option";
    };  
});

.option_vehiculo is a class that I give to all my dropdownlists so I can find them quickly.

I iterate through all my form dropdownlists until I find the one I want to modify. Finding the select I want to change works fine, but I can’t set the selected value, I tried this as I am doing with my input fields:

this.value = "option";

where option is an option inside my dropdownlist, but all I get from this is my dropdownlist with no selected value, it just appears with no text inside and with the possibility to select one of my available options.

How do I set the selected value of a jQuery dropdownlist?


Attempts: I tried with this, but I am getting no results and I am not sure if I can use it with ‘this’ variable as the object I want to modify:

this.val("option");

tried this:

$('#tipo_vehiculo_1000').val("4");
var test = $('#tipo_vehiculo_1000').val();

selecting my dropdownlist by id and trying to change my selected option and outputting it later and it keeps giving me the default value “0”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:46:53+00:00Added an answer on June 5, 2026 at 6:46 am

    Instead of iterating through all of them you can simply use your id value in a jQuery selector

     $('#'+tipo_vehiculo_def).val('option')
    

    This assumes that you have an option tag in the select with value=”option”. Also assumes that since ID’s must be unique in a page you haven’t duplicated any ID’s

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set an option with a specific value as selected (using jQuery).
I'm trying to set the selected value of a DropDownList which sits inside the
I am trying to set the selected value of a combobox from a style
I'm trying to figure out how to set the selected option of a select
I'm trying to set the selected value of my Font Family combobox, which has
I' trying to use a Linq query to find and set the selected value
I'm trying to set the UISwitch selected value and it's not responding! Here is
I have a selectbox and I'm trying to set the value of localStorage.getItem(Selectoption) ,
I am SIMPLY trying to set an ID Value (using ListBox.SelectedValuePath) to a WPF
I'm trying to set a selected value on a dropdown. But before I do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.