How do I get value of select option for current row

Mr Joe

I have dynamic field to generate select option & text input.

var i=$('table tr').length;
$(".addmore").on('click',function(){
    html = '<tr>';
    html += '<td><select name="itemType[]" id="itemType_'+i+'" class="form-control input-sm"><option value="AAA">AAA</option><option value="BBB">BBB</option></select></td>';
    .....
    .....
    html += '</tr>';
    $('table').append(html);
    i++;
});
$(document).on('focus','.autocomplete_txt',function(){
    type = $(this).data('type');
    if(type =='itemName' )autoTypeNo=0;
    $(this).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url : 'ajax',
                dataType: "json",
                method: 'post',
                data: {
                    search : request.term,
                    type : type,
                    select : $("#itemType_"+i).val()
                }
                success: function( data ) {}
            ..

Why the $("#itemType_"+i).val() return an empty value? I have missing something here?

void

Because the current select will have a id say itemType_7 but the value of i will be 8 as you are incrementing it after creating the select.

So the fetch the value of latest select you have created, you should do

$("#itemType_"+(i-1)).val()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I get the text and not the value of an Option?

From Dev

How do I get the current value of a Variable?

From Dev

get value of select option in multiple row

From Dev

How do I to set selected value in a select option using jquery?

From Dev

How do I limit two select option to match some value?

From Dev

How do I to set selected value in a select option using jquery?

From Dev

How I get the text instead value from a select option in CodeIgniter

From Dev

How can I get value when click option in the select on vue?

From Dev

How do I get the value of a datalist option and assign it to another element?

From Dev

How do I SELECT the row with maximum value for an attribute in SQL

From Dev

How do I get value of <select> when a user select a item

From Dev

Get value of a column of a row where select option value changed

From Dev

Get current value when change select option - Angular2

From Dev

how to get current row value in plpgsql function

From Dev

How to get option value of select element

From Dev

How to get the option value of selected in Select dropdown

From Dev

DataTables - How do I get/set the value of a cell in a row?

From Dev

How to get the Current Value using SELECT query

From Dev

how to use the current value of a select option inside input field

From Dev

Magento - How do I get the option ID for an attribute search by option value?

From Dev

Magento - How do I get the option ID for an attribute search by option value?

From Dev

How do I get the value of a soup.select?

From Dev

How do I get all select elements that do not have an option selected using jQuery?

From Dev

How do I get the ng-model of a select tag to get the initially-selected option?

From Dev

How do I select specific values in a row to average if another number in the row equals a certain value?

From Dev

How do I select specific values in a row to average if another number in the row equals a certain value?

From Dev

How do I retrieve select option data-attribute value in ReactJS?

From Dev

how do I enable a button if the option value inside a select tag is changed

From Dev

In Javascript how do I add a new option into Html Select so inserted based on alphabetical value of text

Related Related

  1. 1

    How do I get the text and not the value of an Option?

  2. 2

    How do I get the current value of a Variable?

  3. 3

    get value of select option in multiple row

  4. 4

    How do I to set selected value in a select option using jquery?

  5. 5

    How do I limit two select option to match some value?

  6. 6

    How do I to set selected value in a select option using jquery?

  7. 7

    How I get the text instead value from a select option in CodeIgniter

  8. 8

    How can I get value when click option in the select on vue?

  9. 9

    How do I get the value of a datalist option and assign it to another element?

  10. 10

    How do I SELECT the row with maximum value for an attribute in SQL

  11. 11

    How do I get value of <select> when a user select a item

  12. 12

    Get value of a column of a row where select option value changed

  13. 13

    Get current value when change select option - Angular2

  14. 14

    how to get current row value in plpgsql function

  15. 15

    How to get option value of select element

  16. 16

    How to get the option value of selected in Select dropdown

  17. 17

    DataTables - How do I get/set the value of a cell in a row?

  18. 18

    How to get the Current Value using SELECT query

  19. 19

    how to use the current value of a select option inside input field

  20. 20

    Magento - How do I get the option ID for an attribute search by option value?

  21. 21

    Magento - How do I get the option ID for an attribute search by option value?

  22. 22

    How do I get the value of a soup.select?

  23. 23

    How do I get all select elements that do not have an option selected using jQuery?

  24. 24

    How do I get the ng-model of a select tag to get the initially-selected option?

  25. 25

    How do I select specific values in a row to average if another number in the row equals a certain value?

  26. 26

    How do I select specific values in a row to average if another number in the row equals a certain value?

  27. 27

    How do I retrieve select option data-attribute value in ReactJS?

  28. 28

    how do I enable a button if the option value inside a select tag is changed

  29. 29

    In Javascript how do I add a new option into Html Select so inserted based on alphabetical value of text

HotTag

Archive