[Solved] Get desired value of selectbox through jquery


Problem with script is that you are not handling radio buttons and dropdown while extracting values for posting to server.

JS

var form_data = {
      agent_name: $('#agent_name').val(),
      number: $('#number').val(),
      number_from: $('#number_from').val(),
      number_to: $('#number_to').val(),
      quantity: $('#quantity').val(),
      amount: $('#amount').val(),
      date: $('#date').val(),
      commision: $('#commision').val(),
      profit: $('#profit').val(),
      agent_amount: $('#agent_amount').val(),
      user_id: $('#user_id').val(),
      type: $("#abc_type_"+$("input[name=select_type]:checked").val()).val()
   };

Just replace your form_data with above script. If not works let me know.

This part getting checked value from the radio button.

$("input[name=select_type]:checked").val()

response is like this. 1 or 2 or 3.

$("#abc_type_"+$("input[name=select_type]:checked").val()).val()

Now jquery will get value by targeting the ID. eg #abc_type_1, #abc_type_2, #abc_type_3

0

solved Get desired value of selectbox through jquery