I'd like to know if there is any way to be able to select a whole month in jQuery UI's Datepicker while still being able to select a single day.
I tried 'hacking' it by adding an onClick event to the title div after page load, but switching months seems to completely replace the div, thus losing the onClick.
Are there any other solutions? Or maybe an alternative which offers this option?
Your onClick event should be enough. You just need to use a jQuery event handler that works for dynamic links.
If < jQuery 1.7, use: live()
Else If >= jQuery 1.7, use: on()
If you don't necessarily need it to happen in one datepicker, it might be less confusing to have two of them. Use one to select the start date, and use the other one to select the end date. Once the dates are selected, you will need validation to be sure the selected end date is not before the start date (assuming you want that behavior).
To convert jQuery date picker into mont picker will leads to you bulky code. There are many ways to do this the best one is to hide date blocks by a function over riding method. Any way you can use this plugin for month / year picker.
http://lucianocosta.info/jquery.mtz.monthpicker/
i thing you can but Datepicker in div id="anything"
then use live event click like this without hacking any original code
$("#anything .ui-datepicker-month").live('click',function(){
do any thing :) ;
});
I think this has already been posted here
jQuery UI DatePicker to show month year only
very similar but same effect essentially any date selected in the month displays the month only
Related
I've been scanning the internet for a datepicker that checks in a DB if dates are available or not in the current month, but to my surprise haven't found one! Does anyone know of an datepicker like this? Or any suggestions of a AngularJS datepicker that I can build off of? Hopefully without using jQuery, to not have to include a lib when AngularJS is already loaded.
My idea is that dates in a month are all blocked until that month has been loaded, and when progress bar disappears, available dates are selectable.
Thanks!
You can use angular datetime picker directive.
https://angular-ui.github.io/bootstrap/#!#datepickerPopup
It proivdes props for disable selected date.
As well as you can use Kendo UI datepicker,
https://demos.telerik.com/kendo-ui/datepicker/angular.
To disable any dates you need to retreive all the dates from the database and initiate datepicker with disable dates properties.
Can anyone help me to figure out how can I use the set_select() Form helper in the birthday picker jquery plugin? What i want is if the validation fails the selected month, day and year stay after the page loads. Supposed to be the code needs to be injected in the option for the month only dropdown is
<?php echo set_select('birth[month]', 'here is the value but it is dynamically generated by the plugin','the condition for update function in the future'); ?>
I already figured out to select the dropdowns based on the value in the database using for update function by setting the database value to a hidden input and getting the value through jquery
$('select.birthMonth').find('[value='+myvariable+']').prop('selected',true);
The only problem is when the form validation fails birthdaypicker dropdowns reset to the default values. I cant use jquery to inject the
<?php echo set_select('birth[month]', 'here is the value but it is dynamically generated by the plugin','the condition for update function in the future'); ?>
since the second parameter supposed to be for
set_select
is generated by jquery.
Note : im having problem with month, day and year. if i can figure the month only then it would be easy for other dropdowns. Days also vary per month.
If there are any alternatives other than this plugin, please feel free to comment
set_select is an helper to generate your selects, it's run BEFORE the view is rendered and your jquery is of course initialized after.
You can't use it here, you have to let the plugin handle the select boxes on its own.
According to the plugin's documentation page, you can set "defaultDate" when you initialize the plugin. My recommendation would be something like this when initializing your plugin (in javascript):
'var date = '.$this->input->post("year").'-'.$this->input->post("month").'-'.$this->input->post("day").';
$("#demo").birthdayPicker({
defaultDate: date,
});'
You might need to check the value of date before actually using it, I made this quickly.
I am trying to create a webpage where users can input the start & end date and time for the DIV to appear. After it reaches the end date, the DIV will be deactivated until the users have input another start and end date and time. I have start date and end date column in my MYSQL database. How do I start ? Any hints? Or maybe better suggestions on how this works.
These are the requirements:
- Must allow the questionnaire to be released for a fixed time period
- Should allow the questionnaire to be issued more than once.
Have a look at http://www.php.net/manual/en/function.mysqli-connect.php
This will give you an idea. When you have your code you can come back to this site and ask concrete questions.
setInterval(function(){
$("#YOUR_DIV_ID").hide();
}, 60000);
You can use setInterval using JQuery to hide your DIV I have given 1 minute interval, Else you can remove your div using:
$("#YOUR_DIV_ID").remove();
This is the one of easy way.
so my problem is this. I use the multi datepicker, http://multidatespickr.sourceforge.net/
for a site with news block. i save multiple dates for 1 news item and it works like a charm with php. BUT now my problem is, if someone wants to edit the news , I do get the current dates the news has, in a input field, but that isn't marked on the multi datepicker. problem here is, if they selected 30 dates, and want to exclude one after editing, they have to pick 29 dates again on datepicker, cause they wouldn't be active otherwise. my question here is, is there any way to make the datepicker get the dates from an input field ? FYI I get the same date formats both on getting and selecting from datepicker.
You'll have to show the context in which you use it, but the addDates parameter looks like it does what you want, so on instantiation you would pick up the list of dates from your input field and supply them in this parameter. See also how to pre-select dates.
I'm surprised the datepicker isn't permanently alive and just shows itself, in which case it would know what state it was in from last time it was hidden.
Update: reading even further it seems it uses the dates from an input field anyway. See this demo further in the instructions
I am using Jquery Datepicker. In on of my module (PHP) when i am trying to add package details i need to show the date picker with already selected dates in other color. So that admin will not use those selected dates for new package.
Please help me. Thanks in advance.
Regards,
Prabu
I'm not clear on whether you're trying to limit the selection to a specific date range, or whether you want to disable arbitrary dates within a range.
If it's the former, you should be able to specify minDate and maxDate when initialising datepicker. See here.
If the latter, you should be able to use the beforeShowDay option. There's a nice explanation on this question. The second element of the return value is a class name - using that with some corresponding CSS will allow you to see the colour. You can stop it being selected at all by returning false as the first element of the return value.