jackhammer013
jackhammer013

Reputation: 2297

Get Select Tag Value not Option Value jQuery

Im working on a Laravel Blade Templating and I have this select dropdown,

<select class="form-control" name="{{ $value->columnheader }}" id="{{ $value->columnheader }}" value="{{ $value->costperlead }}" disabled>
   <option value="">---</option>
   <option value="Yes">Yes</option>
   <option value="No">No</option>
  <option value="Possibly">Possibly</option>
</select>

In case they choose yes on the options given, how can I get the value of the select dropdown based from it's id? This value value="{{ $value->costperlead }}"

Thanks!

Upvotes: 0

Views: 788

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

value is associated property for select element. .val() will return the selected option value and not value attribute added in select element.

You can use .attr() attribute name to get the attribute value:

$('.form-control').attr('value');

Working Demo

However i would suggest you to use data-value instead of value for having custom attribute. and then get it using:

 $('.form-control').data('value');

Upvotes: 1

Related Questions