1
When loading the page, I need to check which radio button is selected. Then start the IF, ELSE IF, ELSE
.
html
<input type="radio" name="situacao" id="situacao_reserva" value="R" /> Reserva
<input type="radio" name="situacao" id="situacao_saida" value="S" checked />Saida
<input type="radio" name="situacao" id="situacao_chegada" value="C" />Retornou
JS
$("input[name=situacao]").on('change', function() {
if ($(this).val() == "S") {
$("#data_ini").attr("readonly", true);
$("#data_ini").attr("disabled", "disabled");
$('#tab-kmUsado').css('display', 'none');
} else if ($(this).val() == "C") {
$("#data_fim").attr("readonly", true);
$("#data_fim").attr("disabled", "disabled");
$("#situacao_saida").attr("disabled", "disabled");
$("#data_fim").val(str_data + " " + str_hora);
} else {
}
}).change();
When loading the page, radio saída
, already appears disabled, sedo that it should disable only when it is clicked on radio retornou
.
San, I added
$('#tab-kmUsado').css('display', 'none');
, but it is not running when the page is loaded, only when the radio click is done. Because this?– Tiago
Try
$('#tab-kmUsado').hide();
– Sam
Nor did it.
– Tiago
It only works when I change the radio selection.
– Tiago
Blz, thank you very much.
– Tiago
I fixed it, but use it
$('#tab-kmUsado').hide();
instead of$('#tab-kmUsado').css('display', 'none');
, which is the same thing.– Sam
Gave Cero! Thank you.
– Tiago
Sam, how do I call this command
$(".c").on('change', function(e) {
within theelse if ($(this).val() == "C")
.– Tiago
Man, I’m out. I can see that later for you
– Sam
Blz, I created another post to improve understanding. See https://answall.com/questions/373115/chamar-evento-dentro-de-other-evento-jquery
– Tiago