0
I’m trying to implement a field that can be a select
or a datepicker
.
But when inserting the code into the <div>
causes the operation of the datepicker
. I keep the code down for anyone who can help me.
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="https://code.jquery.com/jquery-1.8.2.js"></script>
<script src="https://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<meta charset="utf-8" />
<script>
$(function() {
$( "#calendario" ).datepicker();
});
</script>
<script>
function desligar(){
var divData = document.getElementById('data');
divData.innerHTML="<p>Data: <select id='calendario'><option value='01/03/2018'>01/03/2018</option><option value='01/04/2018'>01/04/2018</option></select></p>";
}
function ligar(){
var divData = document.getElementById('data');
divData.innerHTML="<p>Data: <input type='text' id='calendario' /></p>";
}
</script>
<title>Calendário jQuery</title>
</head>
<body>
<div id='data'>
<p>Data: <input type="text" id="calendario" /></p>
</div>
<BR>
<BR>
<input type='button' onClick=ligar(); value='calendario'>
<input type='button' onClick=desligar(); value='select'>
</body>
</html>
Guy with a simple "hidden" checkbox and CSS vc can switch between a
input text
and ainput date
. If you want me to put an answer with an example for you to see if it suits you.– hugocsl
I already did.. I loved the idea.. Sometimes thinking outside the box, it’s the best solution.. Thank you very much...
– Jaques Oliveira