Reputation: 19307
There is a field attached to datepicker
:
...
<input type="text" class="datepicker chp_" name="dateDebut" />
...
<?php $this->load->view("footer"); ?>
<script type="text/javascript">
$(document).ready(function() {
var idSpecialite = "<?php echo $this->session->userdata('idSpecialite'); ?>";
if (idSpecialite != 4) {
$("#tab1").find(".chp_").each(function(){
$(this).attr("readonly","");
if ($(this).hasClass("datepicker")) {
$(this).removeClass("datepicker");
}
});
}
});
In the footer there is this :
<script type="text/javascript">
...
$(function() {
$(".datepicker").datepicker({
language: 'fr',
autoclose: true
});
});
</script>
As you can see I want the field to be non-editable in a particular condition. But at runtime when I click the field then the picker still shows and the field's value can be changed when selecting a date ! So how to not show the picker in this case ?
Upvotes: 0
Views: 55
Reputation: 19307
ok , I used the disabled
attribute then the picker did not show :
if (idSpecialite != 4) {
$("#tab1").find(".chp_").each(function(){
$(this).attr("disabled",true);
});
}
Upvotes: 1
Reputation: 1341
try to use this code to make it read-only
$this.attr('readonly','readonly');
also make sure that the value of idSpecialite is not 4, you can convert the result to integer to see it, like this:
var idSpecialite = parseInt("<?php echo $this->session->userdata('idSpecialite'); ?>");
Upvotes: 1