As you can see I took the value entered in the date field and put as link. The way I did was by focusout()
, but you can do by N events. What I recommend is by keycode
and focusout()
To see the link, right-click on I am the link and go on inspecting element, see that the href="~/PostoDeServico/ImprimirEscalaPapeleteExecGeral/2020-02-14"
$("#dataInicio").focusout(function(){
if($(this).val() != "dd/mm/aaaa"){
var link = $(this).val()
$(".link_date").attr("href",`${"~/PostoDeServico/ImprimirEscalaPapeleteExecGeral/"+link}`)
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="date" id="dataInicio"><br>
<a href="" class="link_date" id="link_data_1">Eu sou o link</a><br>
<a href="" class="link_date" id="link_data_2">Eu sou o link 2</a><br>
<a href="" class="link_date" id="link_data_3">Eu sou o link 3</a>
In case I don’t know how you need the date, but the default way it comes is: 2020-02-14
For you to modify it the way you want to do the following:
Within the function focusout()
I declared the link variable, therefore
link = link.split("-")
link = link[2]+"/"+link[1]+"/"+link[0] //formato 14/02/2020
//OU -------------------->
link = link[0]+"/"+link[2]+"/"+link[1] //formato 2020/14/02
//OU -------------------->
link = link[2]+"-"+link[1]+"-"+link[0] //formato 14-02-2020
Well I hope to help, good luck
You can use Javascript in this project?
– Azzi
Yes I can use.
– Ricardo Costa Oliveira Santos
Come on then, you’ve got
id
in those fields?– Azzi