How to send Text from Listboxt by GET?

1

I am passing some parameters using javascript via GET to my controller. One of them is a field of type listboxt(select) , however I can not get the value of the selected text to show it in my result, but rather the text that shows me is [object Object]

How can I pass the text value correctly? Thank you in advance.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>

<script>

  $(document).ready(function(){

    $('#btn_buscar').on('click', function(){

      var fecha_ini =  $("#fecha_ini").val();
      var fecha_ter =  $("#fecha_ter").val();
      var rut_usu =  $("#rut_usu").val() ;
      var jc = $("#rut_usu").val($( "#rut_usu option:selected" ).text());


     window.open('<?php echo base_url();?>C_Porcentaje/tabla_porcentaje?fecha_ini=' + fecha_ini + '&fecha_ter=' + fecha_ter + '&rut_usu=' + rut_usu + '&jc=' + jc);

      });

    });

  </script>
    
asked by CristianOx21 26.10.2017 в 00:44
source

1 answer

0

To select the text of the selected option tag, it is not necessary to first select the value of the select and then the text of the option as you are doing, you were very close to achieving it! just do the following:

var jc = $( "#rut_usu option:selected" ).text();
    
answered by 26.10.2017 / 00:58
source