Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Can someone help me ?

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can someone help me ?

    i have calendar code , but it has bog in it . can someone help me fix it .
    i have datepicker ... i want it to take dates as "dd.mm.yy" but it takes them as "mm.dd.yy"
    first part of the script is bugged ... but im new in java and i cant fix it ...

    	$(function() {
    	var disabledDaysRange = [["15.04.2011 to 15.05.2011"]];
     
    function disableRangeOfDays(d) {
     
        for(var i = 0; i < disabledDaysRange.length; i++) {
     
            if($.isArray(disabledDaysRange[i])) {
     
                for(var j = 0; j < disabledDaysRange[i].length; j++) {
     
                    var r = disabledDaysRange[i][j].split(" to ");
     
                    r[0] = r[0].split(".");
     
                    r[1] = r[1].split(".");
     
                    if(new Date(r[0][2], (r[0][0]-1), r[0][1]) <= d && d <= new Date(r[1][2], (r[1][0]-1), r[1][1])) {  ///i think maybe that part is bugged
     
                        return [false];
     
                    }
     
                }
     
            }else{
     
                if(( d.getDate()+ '.' + (d.getMonth()+1) + '.' + d.getFullYear()) == disabledDaysRange[i]) {
     
                    return [false];
     
                }
     
            }
     
        }
     
        return [true];
     
    }
    		var dates = $( "#from, #to" ).datepicker({
    			defaultDate: "+1w",
    			dateFormat: 'dd.mm.yy',
    			beforeShowDay: disableRangeOfDays,
    			changeMonth: true,
    			numberOfMonths: 3,
    			onSelect: function( selectedDate ) {
    				var option = this.id == "from" ? "minDate" : "maxDate",
    					instance = $( this ).data( "datepicker" );
    					date = $.datepicker.parseDate(
    						instance.settings.dateFormat ||
    						$.datepicker._defaults.dateFormat,
    						selectedDate, instance.settings );
    				dates.not( this ).datepicker( "option", option, date );	
    			}
    		});
    	});

    PHP Code:
    <html>
    <head>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
     <script src="/jquery.ui.datepicker-et.js"
        type="text/javascript"></script>


    <form name="all1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >

    <script>
        $(function() {
        var disabledDaysRange = [["03.04.2011 to 04.05.2011"]];

    function disableRangeOfDays(d) {

        for(var i = 0; i < disabledDaysRange.length; i++) {

            if($.isArray(disabledDaysRange[i])) {

                for(var j = 0; j < disabledDaysRange[i].length; j++) {

                    var r = disabledDaysRange[i][j].split(" to ");

                    r[0] = r[0].split(".");

                    r[1] = r[1].split(".");

                    if(new Date(r[0][2], (r[0][0]-1), r[0][1]) <= d && d <= new Date(r[1][2], (r[1][0]-1), r[1][1])) {

                        return [false];

                    }

                }

            }else{

                if(( d.getDate()+ '.' + (d.getMonth()+1) + '.' + d.getFullYear()) == disabledDaysRange[i]) {

                    return [false];

                }

            }

        }

        return [true];

    }
            var dates = $( "#from, #to" ).datepicker({
                defaultDate: "+1w",
                dateFormat: 'dd.mm.yy',
                beforeShowDay: disableRangeOfDays,
                changeMonth: true,
                numberOfMonths: 3,
                onSelect: function( selectedDate ) {
                    var option = this.id == "from" ? "minDate" : "maxDate",
                        instance = $( this ).data( "datepicker" );
                        date = $.datepicker.parseDate(
                            instance.settings.dateFormat ||
                            $.datepicker._defaults.dateFormat,
                            selectedDate, instance.settings );
                    dates.not( this ).datepicker( "option", option, date );    
                }
            });
        });
        </script>
        
    <div class="demo">

    <label for="from"><b>Algus</b></label>
    <input type="text" id="from" name="from"/>
    <label for="to"><b>Lõpp</b></label>
    <input type="text" id="to" name="to"/>
    <?php
    include("connect_db.php");

    if(isset(
    $_POST['submit'])) 
    {
        if (
    $_POST["from"] == 0)
            {
                echo 
    '<tr><td align="center"><h4>Palun valige algus kuupäev!</h4></td></tr>';
            }
        else
            {
            

                            if (
    $_POST["to"] == 0)
                            {
                                echo 
    '<tr><td align="center"><h4>Palun valige lõpu kuupäev!</h4></td></tr>';
                            }
                            else
                            
                            {


                            }
                            }
                            }
                            
                            
                            
                            

    @
    $alg $_POST['from'];
    @
    $lop $_POST['to'];
    echo 
    "<b><h3>$alg - $lop</h3></b>";
    ?>
    <?php
    if(isset($_POST['submit']))
    {
    $january = new DateTime("$alg");
    $february = new DateTime("$lop");
    $interval $february->diff($january);
    echo 
    $interval->format('<b><h3>%m Kuid, %d Päevasid</h3></b>');
    }
    ?>

    <table border='0' width='250'>
    <tr><td align="right"><input type="submit" name="submit" value="Edasi" /></td></tr>
    </form>
     </table>
      
     
    </head>
    <body style="font-size:62.5%;">
      
    <div type="text" id="datepicker"></div>

    </body>
    </html>
    Last edited by Cover; February 5th, 2011 at 07:24 AM.

  2. #2
    Member DanBrown's Avatar
    Join Date
    Jan 2011
    Posts
    134
    My Mood
    Confused
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Default Re: Can someone help me ?

    my dear ,
    we are here to help, but can you plz be more specific regarding the bug and your problem.
    So that it will be easy for us to understand the problem.
    Thanks and Regards
    Dan Brown

    Common Java Mistakes

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can someone help me ?

    added some info

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Can someone help me ?

    This looks like JavaScript to me. I'm afraid Java and JavaScript are two different languages..
    I suggest you Google a JS forum. Thanks.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.