select - Set selected value jQuery dropdownlist -
i trying set selected value in dropdownlist using jquery, have this:
$('.option_vehiculo', '#form_login').each(function() { if (this.id == tipo_vehiculo_def) { this.value = "option"; }; }); .option_vehiculo class give dropdownlists can find them quickly.
i iterate through form dropdownlists until find 1 want modify. finding select want change works fine, can't set selected value, tried doing input fields:
this.value = "option"; where option option inside dropdownlist, dropdownlist no selected value, appears no text inside , possibility select 1 of available options.
how set selected value of jquery dropdownlist?
attempts: tried this, getting no results , not sure if can use 'this' variable object want modify:
this.val("option"); tried this:
$('#tipo_vehiculo_1000').val("4"); var test = $('#tipo_vehiculo_1000').val(); selecting dropdownlist id , trying change selected option , outputting later , keeps giving me default value "0".
instead of iterating through of them can use id value in jquery selector
$('#'+tipo_vehiculo_def).val('option') this assumes have option tag in select value="option". assumes since id's must unique in page haven't duplicated id's
Comments
Post a Comment