Reputation: 117
Prefer this example so you have better idea for give answer
<select id="cmbfotos" onchange="aplicarFoto()">
<option value="gokussj3.jpg">Value 1</option>
<option value="gokussj4.jpg">Value 2</option>
<option value="gohanssj2.jpg">Value 3</option>
<option value="gotenks.jpg">Value 4</option>
<option value="krilin.jpg">Value 5</option>
</select>
In above ex. when i select two value like Value1 and value2 both value i require so how to i get it.
i not require value like "gokussj3.jpg" but Value 1
If some idea share me .....
Upvotes: 1
Views: 80
Reputation:
Use this solution for your requirement
// Use for multiple select in select
$('#cmbfotos option').each(function()
{
if($(this).val() == 'gokussj3.jpg')
{
$(this).prop("selected", true);
}
});
// Get the value from a drop down select
$( "#cmbfotos option:selected").val();
// Get the value from a dropdown select even easier
$( "select.foo" ).val();
// Get the value from a checked check box
$( "input:checkbox:checked" ).val();
// Get the value from a set of radio buttons
$( "input:radio[name=bar]:checked" ).val();
Upvotes: 1
Reputation: 832
$('#cmbfotos option:selected').text(); ////is for text and
$('#cmbfotos option:selected').val() ///is for value;
Upvotes: 1