Jump to content

erme

Members
  • Posts

    188
  • Joined

  • Last visited

Posts posted by erme

  1. Hi, I have 2 inputs called ArrivalDate and DepartureDate using jQuery datepicker which needs to det the departure date at least one more day from the selected arrival date. All works fine, except when we reach the end of the month insted of the departure date rolling over to the next month it just +1's the date. Eg today its showing 31 April, which dosent exsist.

    $.datepicker.setDefaults({
        changeMonth: true,
        changeYear: true,
        dateFormat: 'd/m/yy',
        firstDay: 1
    });
    
    var myDate = new Date();
    var prettyDate = myDate.getDate() + '/' + (myDate.getMonth()+1) + '/' + myDate.getFullYear();
    var prettyDate2 = (myDate.getDate()+1) + '/' + (myDate.getMonth()+1) + '/' + myDate.getFullYear();        
        
    $('#ArrivalDate').datepicker({
        minDate: new Date(),
        onSelect: function(dateStr) {
            var min = $(this).datepicker('getDate') || new Date(); // Selected date or today if none
            $('#DepartureDate').datepicker('option', {minDate: min});
        }
    });
    $('#DepartureDate').datepicker({
        minDate: new Date(),
        onSelect: function(dateStr) {
            var max = $(this).datepicker('getDate'); // Selected date or null if none
            $('#ArrivalDate').datepicker('option', {maxDate: max});
        }
    });    
    
    $("#ArrivalDate").val(prettyDate);
    $("#DepartureDate").val(prettyDate2);
    
    
  2. I have 2 radio buttons.

    <input type="radio" name="toasted" id="toasted_sandwiches" value="Toasted Sandwiches" onclick="handleClick();" /> 
    <input type="radio" name="toasted" id="toasted_paninis" value="Toasted Paninis" onclick="handleClick();" /> 

    I want a function that only adds an event (in this case its spry validation) to what radio button is selected. Currently if the user clicks from one radio to the other, both spry events get called.

    function handleClick() {
                    if (document.getElementById("toasted_sandwiches").checked == true) {
                        var spry_toasted_sandwiches = new Spry.Widget.ValidationCheckbox("spry_toasted_sandwiches", {minSelections:3, validateOn:["change", "blur"]});
                    }
                    else if (document.getElementById("toasted_paninis").checked == true) {
                        var spry_paninis = new Spry.Widget.ValidationCheckbox("spry_paninis", {minSelections:3, validateOn:["change", "blur"]});
                    }
    
                }
  3. I have a series of images in a div called .img_wrapper. I want to add a class to this div based on whether the image in the div is landscape or portrait.

     

    This is what I have come up with but doesn't work:

     $(".img_wrapper").each(function(){    
    
        var img = $(".img_wrapper img");
        var div = $(".img_wrapper");
    
        if (img.height() < img.width()){
            div.addClass('landscape');
        } else {
            div.addClass('portrait');
        }
    
    });
  4. Okay thanks for your replies. Basically what I am trying to achieve is the ability for the user to be able to edit a page on a website (this bit I have done, using 'update pages') and select from a drop down box an offer that appears in the SQL table 'offers'.

  5. Hi, bit of a newbie question.

     

    I have a table called pages. I select all from this table. I need to also show the rows of another table called offers so the user can select an offer to display on this page.

     

    Question is, how do I select from both tables.

     

    pages table colums:

    ID

    Name

    Copy

     

    offers table columns:
    OffersID     
    OffersTitle     
    OffersDate           
    OffersCopy                
    OffersType
    OffersPrice            
     

    I have tried variations of the below but does not work:

     

    SELECT * FROM pages
    WHERE id = '" . $id . "'
    LEFT JOIN offers

     

     

  6. This is a working example, there are a couple ways you could tweak this depending on your needs.

    http://jsfiddle.net/fastsol/6nXxe/1/

    I wanted to do the check on keyup but then you couldn't even change the last number cause it would obviously be less than the 1.55, so went with focusout instead.

     

    Perfect, however is there an obvious reason why it wouldn't work in IE?

     

    Actually it does. I'm just being stupid!

  7. Hi,

     

    I currently have one table with a column called box, which will have values of 'one', 'two', 'three' etc. There will be 8 boxes to display on the site. The site needs to display the newest row according to column added (which will have the date added as a value). I am thinking of writing the code below to populate the 8 boxes:

    while($row1 = mysql_fetch_assoc(mysql_query("SELECT * FROM table WHERE box = 'one' ORDER BY added DESC LIMIT 1"))) {
        
        //echo box 1
        
    }
    
    while($row2 = mysql_fetch_assoc(mysql_query("SELECT * FROM table WHERE box = 'two' ORDER BY added DESC LIMIT 1"))) {
        
        //echo box 2
        
    }
    
    while($row3 = mysql_fetch_assoc(mysql_query("SELECT * FROM table WHERE box = 'three' ORDER BY added DESC LIMIT 1"))) {
        
        //echo box 3
        
    }
    
    while($row4 = mysql_fetch_assoc(mysql_query("SELECT * FROM table WHERE box = 'four' ORDER BY added DESC LIMIT 1"))) {
        
        //echo box 4
        
    }

    etc....

     

    Is there a better way to streamline this?

     

    Many thanks

  8. Store them as normal. Your script that displays posts, should only query for posts where the published date is in the past.

     

    SELECT * FROM posts WHERE published_date <= NOW()

     

    etc.

     

    Thanks for your reply. What format will the date and time need to be stored as for this to work? Currently it is stored like this 2013043014:14:35

  9. Hi, I've created a CMS that enables the user to publish an article which will appear on the site immediately. I need to add in the option to schedule displaying the article.

     

    I have a field in the MySQL table for pubished_date. How can I write something in PHP that won't display articles where published_date is in the future / hasn't arrived yet?

     

    I could then maybe set up a cron job to run the script every night.

     

    Thanks in advance...

  10. Hi, I only want a bit of javascruipt to run when window width is larger then 768px. In other words, for mobile devices I dont want it to load. This needs to work when resizing the browser window.

     

    var delay = (function(){
       var timer = 0;
       return function(callback, ms){
        clearTimeout (timer);
        timer = setTimeout(callback, ms);
       };
    })();
    
    $(function() {
    
       var pause = 100; // will only process code within delay(function() { ... }) every 100ms.
    
       $(window).resize(function() {
    
        delay(function() {
    
    	    var width = $(window).width();
    
               if( width >= 768 ) {
    
                   var carouselOptions = {
                       auto: true,
                       btnNext: "#quicklinks_right",
                       btnPrev: "#quicklinks_left",
                       visible: 4,
                       speed: 1000,
                       pause: true,
                       responsive: true
                   };
    
                   $('#quicklinks').jCarouselLite(carouselOptions);
    
                   $("ul.sf-menu").superfish({
                       animation: {height:'show'}, // slide-down effect without fade-in
                       delay: 800    
                   });
    
               }
    
               else if( width <= 767 ) {
    
                   $('#quicklinks').unbind(); // not sure if this works?
    
                   $("ul.sf-menu").unbind(); // not sure if this works?
    	    }
    
    
        }, pause );
    
       });
    
       $(window).resize();
    
    });

  11. <?php
       $uri = $_SERVER['REQUEST_URI'];
    
       $directory = $_SERVER['DOCUMENT_ROOT'].'/img/banner' . $uri . '/';
    
       $images = glob($directory . "*.jpg");
    
    
       foreach($images as $image)
       {
           $test = explode("/" , $image);
    
           echo "<pre>".print_r($test)."</pre>";
    
           echo '<img class="slide" src="' . $image . '" alt="">';
       }
    ?>

     

    Basically it gets all .jpg files from a folder as per the URI. I need document root to call the folder, but don't want it to render the image in HTML

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.