0

I need to change dates

In fact I have inputs with datepicker class

I have also dates recorded in my database as strike days

What I need to do is to check if the date in the input is one of this strikedays if the date is one of this strikedays, I need to put the next day

the same things, if the date is sunday, because it is a closed day.

I've tried something like that

    <script type="text/javascript">
    $(document).ready(function(){
        $('.datepicker').change(function(){
            //Définition des jours interdits :

<?php
            $query = "SELECT `date`, `date2` FROM `jours_feries`";
            $result = mysql_query($query);
            while ($date = mysql_fetch_assoc($result)):
                ?> 
                            alert($(this).val());
                            if($(this).val()=='<?php echo date('d-m-Y',strtotime($date['date'] ))?>'){
                            $(this).val(<?php echo date('d-m-Y',strtotime($date['date2'])) ?>)
                }
            <?php endwhile; ?>

        })  
    })

</script>

which give to me (printed source)

                  <script type="text/javascript">
$(document).ready(function(){
    $('.datepicker').change(function(){
        //Définition des jours interdits :


                        alert($(this).val());
                        if($(this).val()=='25-12-2013'){
                        $(this).val(26-12-2013)
            }

    })  
})

I do not know how to proceed to go on for the sunday, to check it

I also would like to replace dates (onload, onblur, on what so ever event can change it)

Anykind of help will be much appreciated

Stanislas Piotrowski
  • 2,595
  • 10
  • 40
  • 59
  • Nothing to say. I will refer this [http://stackoverflow.com/questions/11938805/php-code-inside-a-javascripts-document-write](http://stackoverflow.com/questions/11938805/php-code-inside-a-javascripts-document-write). You can't use `Client-Side` and `Server-Side` script at once. You have to separate it. DOM will sho you the result as html. But functionality it's totally not working. Use `AJAX` you can do it. – yeshansachithak Apr 28 '14 at 08:58

1 Answers1

1

use on() for bind multiple event

$(document).ready(function(){
    $('.datepicker').on("change blur load",function(){
        //Définition des jours interdits :
                        alert($(this).val());
                        if($(this).val()=='25-12-2013'){
                        $(this).val("26-12-2013");// here you forget to wrap value in "";
            }

    })  
})
Rituraj ratan
  • 10,260
  • 8
  • 34
  • 55