3
My Select is like this:
<select class="input-medium ajuste" id="sel_mes">
<option value="09/03/2014">Março - 2014</option>
<option value="09/04/2014">Abril - 2014</option>
<option value="09/05/2014">Maio - 2014</option>
<option value="09/06/2014">Junho - 2014</option>
<option value="09/12/2015">Dezembro - 2015</option>
<option value="09/01/2016">Janeiro - 2016</option>
</select>
I want to get the value, which is the date 09/04/2014
and not the text Abril - 2014
I’m using this:
var ValorA = $("#sel_mes").val();
I’ve tried this one too
var ValorA = $("#sel_mes option:selected").val();
But both return Abril - 2014
Colote via Jquery Thus
function montaMeses(data){
$.ajax({
async: false,
type: "POST",
url: "../execs/proc_fluxocaixa.php",
data: {d_acao: "meses", c_data: data},
dataType: "json",
success: function(ret_dados){
$("#sel_mes").html(ret_dados.meses);
}
});
}
IN PHP
function MesExt($mes){
if ($mes == 1) {return "Janeiro";};
if ($mes == 2) {return "Fevereiro";};
if ($mes == 3) {return utf8_encode("Março");};
if ($mes == 4) {return "Abril";};
if ($mes == 5) {return "Maio";};
if ($mes == 6) {return "Junho";};
if ($mes == 7) {return "Julho";};
if ($mes == 8) {return "Agosto";};
if ($mes == 9) {return "Setembro";};
if ($mes == 10){return "Outubro";};
if ($mes == 11){return "Novembro";};
if ($mes == 12){return "Dezembro";};
}
if($acao == "meses"){
$optMeses = "";
$atual = $_POST["c_data"];
$Data = explode("/", $atual);
$a1 = explode("/", $Sv->somar_data($atual, 0, 12, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 12, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 11, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 11, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 10, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 10, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 9, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 9, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 8, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 8, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 7, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 7, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 6, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 6, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 5, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 5, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 4, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 4, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 3, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 3, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 2, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 2, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 1, 0, false)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 1, 0, false) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $atual); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value'$atual' selected>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 1, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 1, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 2, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 2, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 3, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 3, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 4, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 4, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 5, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 5, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 6, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 6, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 7, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 7, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 8, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 8, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 9, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 9, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 10, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 10, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 11, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 11, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$a1 = explode("/", $Sv->somar_data($atual, 0, 12, 0, true)); $MesExtenso = MesExt($a1[1]); $AnoExtenso = $a1[2]; $optMeses .= "<option value='" . $Sv->somar_data($atual, 0, 12, 0, true) . "'>$MesExtenso - $AnoExtenso</option>";
$retorno["meses"] = $optMeses;
}
You could put the html of your select?
– Rafael Withoeft
<select class="input-medium tuning" name="sel_account" id="sel_account"></select>, but is fed via jquery. But it is feeding right.
– Joel Henrique Rother
$("#sel_mes option:selected").val();
works as expected.– Luis Henrique