Page 1 of 1

jquery date picker ristrict date range

Posted: Fri Jun 15, 2012 5:36 am
by jonnyfortis
I have a date picker that currently gives a full date range and works fine. the date picker is for people to select when they move into a certain property. that is held in a PHP DB. i want to be able to be able to set the date picker to only show the dates when the property is available to move into. Ideally the available move in date is set up in the backed of the system so therefore stored in the DB

i have all the code is required.

i am using PHPmyadmin SQL

Re: jquery date picker ristrict date range

Posted: Fri Jun 15, 2012 9:41 am
by pickle

Re: jquery date picker ristrict date range

Posted: Fri Jun 15, 2012 9:48 am
by jonnyfortis
i have seen this but does this show you how to administer via a php back end

Re: jquery date picker ristrict date range

Posted: Fri Jun 15, 2012 10:05 am
by pickle
Just echo the date from PHP into a javascript variable, then use that variable in your javascript.

Re: jquery date picker ristrict date range

Posted: Sat Jun 16, 2012 8:48 am
by jonnyfortis
pickle wrote:Just echo the date from PHP into a javascript variable, then use that variable in your javascript.

ok can you give me a clue howi do this? it would be of great help

Re: jquery date picker ristrict date range

Posted: Mon Jun 18, 2012 9:47 am
by pickle

Code: Select all

<script type = "javascript">
var minDate = '<?php echo $the_date_from_the_database; ?>';

$("selector").datepicker({minDate: minDate});
</script>
You may need to do some formatting to convert the date in the database to a format usable by datepicker, but that's the general way to do it

Re: jquery date picker ristrict date range

Posted: Tue Jun 19, 2012 5:09 am
by jonnyfortis
pickle wrote:

Code: Select all

<script type = "javascript">
var minDate = '<?php echo $the_date_from_the_database; ?>';

$("selector").datepicker({minDate: minDate});
</script>
You may need to do some formatting to convert the date in the database to a format usable by datepicker, but that's the general way to do it

ok thanks

this is the script i have at the moment, basically what i have is field one is the datpicker, i then have 2 radio button one for 43 weeks and the other for 52 weeks. what ever they select it will give the datepicker date plus the 34 / 52 weeks

<script type="text/javascript">
$(function(){

$('.date-pick').datepicker({ dateFormat: 'dd/mm/yy' });

$("input[name='weeks']").change(function() {

var start = $('input[name="StartDate"]').val();
var weeks = $('input:radio[name="weeks"]:checked').val();

var date = new Date(start);
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();

myInteger = parseInt(weeks);

var edate= new Date(y, m, d+myInteger);

edate = edate.format("dd/mm/yyyy");

$('input[name="EndDate"]').val(edate);

});


});
</script>


<input type="text" value="" name="StartDate" id="StartDate" class="date-pick" size="30" />

<td width="180" class="table-text"><input type="radio" value="364" name="weeks" validate="required:true" />
52 weeks &nbsp;
<input type="radio" value="301" name="weeks" />
43 weeks</td>

<input type="text" value="" name="EndDate" id="EndDate" size="30" />


so i need to add a column in the db that will show the min date? how do i add that code to my existing code?


thanks so much for you help

Re: jquery date picker ristrict date range

Posted: Tue Jun 19, 2012 9:42 am
by pickle
All your code is javascript (which you should wrap in

Code: Select all

[/script] tags).  To add a column to your DB, you'll need to do some work in SQL, and some PHP code.

Generally questions that get answered are of the format, "I've tried X, here is my code, the problem I'm having is Y".  It's difficult for me at least, to just do the work for you.

Re: jquery date picker ristrict date range

Posted: Tue Jun 19, 2012 9:58 am
by jonnyfortis
pickle wrote:All your code is javascript (which you should wrap in

Code: Select all

[/script] tags).  To add a column to your DB, you'll need to do some work in SQL, and some PHP code.

Generally questions that get answered are of the format, "I've tried X, here is my code, the problem I'm having is Y".  It's difficult for me at least, to just do the work for you.[/quote]


ok all the code is already wrapped in the tags as you suggested. i am trying to get it working myself.

thanks for your time

Re: jquery date picker ristrict date range

Posted: Wed Jun 27, 2012 4:24 am
by jonnyfortis
jonnyfortis wrote:
pickle wrote:All your code is javascript (which you should wrap in

Code: Select all

[/script] tags).  To add a column to your DB, you'll need to do some work in SQL, and some PHP code.

Generally questions that get answered are of the format, "I've tried X, here is my code, the problem I'm having is Y".  It's difficult for me at least, to just do the work for you.[/quote]


ok all the code is already wrapped in the tags as you suggested. i am trying to get it working myself.

thanks for your time[/quote]


I have looked at what i need to do but am totally stuck. i would say i have tried x to get to y but dont really know where to start

Re: jquery date picker ristrict date range

Posted: Wed Jun 27, 2012 9:44 am
by pickle
Start at getting the javascript to do what you want. Then update your database to have a new column. Finally, update your PHP code to take what is given from Javascript, and properly put it in the database.

Re: jquery date picker ristrict date range

Posted: Thu Jun 28, 2012 5:08 am
by jonnyfortis
pickle wrote:Start at getting the javascript to do what you want. Then update your database to have a new column. Finally, update your PHP code to take what is given from Javascript, and properly put it in the database.

i understand the concept just having trouble linking it in.