How to pass a different value in an HTML form?

2

I am creating an HTML date filter so that the SQL query can return a specific value to me.

I'm just trying to pass this information on because the form option needs to appear in the month as <option>Março</option> .

My SQL query looks like this:

select codigo, id_usuario, codigo_usuario, data, hora, despesa, valor, modo, observacao, estabelecimento, genero, tipo from despesa where id_usuario = 1 and data between '2015-Março-01' and '2015-Março-31' ;

I would like to be able to select the March option in the form and it will change that month to 03, so I can do a select right.

I was just wondering if there is an easier way to do this right in the direct HTML form.

Thank you.

    
asked by anonymous 08.09.2016 / 04:23

2 answers

7

Just add a value to your option. See:

$(document).on('change', '#meses', function(){
  var mes = this.value;
  alert(mes);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><selectid="meses">
  <option value="01">Janeiro</option>
  <option value="02">Fevereiro</option>
  <option value="03">Março</option>
  <option value="04">Abril</option>
  <option value="05">Maio</option>
  <option value="06">Junho</option>
  <option value="07">Julho</option>
  <option value="08">Agosto</option>
  <option value="09">Setembro</option>
  <option value="10">Outubro</option>
  <option value="11">Novembro</option>
  <option value="12">Dezembro</option>
</select>
    
08.09.2016 / 04:30
-3

It is currently best to use the HTML5 DatePicker. It will allow you to select the date and will pass it already formatted the same as the server works. In case there in particular you will have to handle the dates, and take out the month, from 2015-March-01 and serialize. The return starts at 0 not at 1. So if you use the datepicker you will already be able to select the direct date and month in the input, to send or receive from your request via sql.

    
23.10.2018 / 10:49