Top Questions

  • 5.11 Years

    • Category : Css
    • Location : Mohali
    • Posted On : May 9, 2016

    this css class add your bootstrap modal then see the magic

    rotate {
        transform:rotate(180deg);
        transition:all 0.5s;
    }
    .rotate.in {
        transform:rotate(1800deg);
        transition:all 1.5s;
    }
  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Feb 22, 2018

    This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument.

    add_action( 'user_register', 'eddpremium_register_fields_save');
    add_action( 'profile_update', 'eddpremium_register_fields_save');
    
    function eddpremium_register_fields_save($user_id) {
    	$u = new WP_User($user_id);
    
    	// Remove role
    	$u->remove_role( 'subscriber' );
    
    	// Add role
    	$u->add_role( 'author' );
    }
     
  • 5.11 Years

    • Category : Jquery
    • Location : Mohali
    • Posted On : Jun 9, 2016

    I use a datepicker for choosing an appointment day.I want to exclude Saturdays and Sundays from the available choices. Can this be done? If so, how?

    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <input name="datenew" type="text" id="datepicker">
    <script>
    var unavailableDates = ["21-6-2016","22-6-2016","23-6-2016","24-6-2016"];
    function unavailable(date) {
      var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
        dmy = date.getDate()   "-"   (date.getMonth()   1)   "-"   date.getFullYear();
      var closedDays = [[Saturday],[Sunday]];
     for (var i = 0; i < closedDays.length; i  ) {
        if (day == closedDays[i][0]) {
          return [false];
       }
    
     }
        if (jQuery.inArray(dmy, unavailableDates) == -1) {
            return [true, ""];
        } else {
            return [false, "", "Unavailable"];
        }
    }
    jQuery(function() {
      jQuery( "#datepicker" ).datepicker({    
        changeMonth: true,
        changeYear: true,
       dateFormat: 'dd MM yy',   
        autoclose: true,
        minDate:  2,
        firstDay: 1,
        beforeShowDay: unavailable
      });
    
    });
    </script>
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jan 7, 2016
    if(isset($_GET['mintime']) && isset($_GET['maxtime'])){
        $extraconditionsa = $extraconditionsa ."and TIME_FORMAT (
       str_to_date (
           replace (hour,':',''),'%H%i'),'%H:%i') between '{$_GET['mintime']}' AND '{$_GET['maxtime']}'";
    }
    
    // mysql:How do I check if a column is empty or null in mysql
    SELECT * FROM table_name WHERE NULLIF(some_col, '') IS NULL;

     

  • 2.11 Years

    • Category : Jquery
    • Location : Chandigarh, India
    • Posted On : Feb 4, 2019

    If you want to create a web page form like contact form or any other form text field. if you want to allow only numeric letters like (0-9)

    <input name="number">
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
    <script type="text/javascript">
    // Numeric only control handler
    jQuery.fn.ForceNumericOnly =
    function()
    {
        return this.each(function()
        {
            $(this).keydown(function(e)
            {
                var key = e.charCode || e.keyCode || 0;
                // allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
                // home, end, period, and numpad decimal
                return (
                    key == 8 || 
                    key == 9 ||
                    key == 13 ||
                    key == 46 ||
                    key == 110 ||
                    key == 190 ||
                    (key >= 35 && key <= 40) ||
                    (key >= 48 && key <= 57) ||
                    (key >= 96 && key <= 105));
            });
        });
    };
    $('input[name="number"]').ForceNumericOnly();
    </script>
  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Feb 20, 2018

    The hook allows meta box registration for any post type. Passes two parameters: $post_type and $post. Note: You can also use add_meta_boxes_{post_type} for best practice, so your hook will only run when editing a specific post type. This will only receive 1 parameter - $post.

    Add this to functions.php
    add_action( 'add_meta_boxes', 'gp_add_meta_boxes' );
    function gp_add_meta_boxes() {
        add_meta_box( 'gp_product', 'Products Options', 'gp_products_callback', 'review', 'normal', 'high' );
    }
    
    function gp_products_callback( $post ) {
        $fname = get_post_meta( $post->ID, 'fname', true );
    
    // reset choices
    	$field['choices'] = array();
    	
    	$users = get_users();
    	?>
    	<select name="cust_user"></select>
    	<?php
    	foreach ($users as $user) {
    		$field[ $user->ID ] = $user->display_name;
    	}
    
        ?>
        <p>First Name: <input type="text" name="fname" value="<?php echo $fname; ?>"></p>
        <?php
    }
     
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Jan 22, 2016

    add confirmation alert before your link active

    <script>
    function confirmDelete(delUrl) {
      if (confirm("Are you sure you want to delete")) {
        document.location = delUrl;
      }
    }
    </script>
    
    <a href="javascript:confirmDelete('delete.page?id=1')">Delete</a>
    
    or
    
    <a href="delete.page?id=1" onclick="return confirm('Are you sure you want to delete?')">Delete</a>
    
    or
    use this cdn's in your header
    
    https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.css
    https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.js
    
    
    <a href="delete.page?id=1" class="confirmation">Delete</a>
    
    jQuery('.confirmation').click(function (e) {
        var href = jQuery(this).attr('href');
    
        swal({
            title: "Are you sure?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes",
            cancelButtonText: "No",
            closeOnConfirm: true,
            closeOnCancel: true
        },
                function (isConfirm) {
                    if (isConfirm) {
                        window.location.href = href;
                    }
                });
    
        return false;
    });
    

  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Sep 20, 2017

    Display countdown timer using jQuery.

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-countdown/2.0.2/jquery.countdown.min.js" ></script>
    
    /*html*/
    
    <span data-countdown="2017-09-25 12:10:01" ></span> // end date add here
    
    
    /*Jquery*/
    
    setTimeout(function(){
                    initCountDown()
    }, 300);            
    function initCountDown(){
        $('[data-countdown]').each(function() {
            var $this = $(this), finalDate = $(this).data('countdown');
            $this.countdown(finalDate, function(event) {
                $this.html(event.strftime('%D days %H:%M:%S'));
            });
        });
    }  
     
  • 0.0 Years

    • Category : Wordpress
    • Location : Unknown
    • Posted On : Mar 22, 2016

    Get Posts By Sub Category ID in Wordpress.

    <?php query_posts('cat=10&showposts=-1');
               $posts = get_posts('category=10&numberposts=3&offset=0');
                foreach ($posts as $post) : start_wp(); ?>
    
                <?php $cats = get_the_category($post->ID);
                $subcategories = array();
                foreach( $cats as $cat ) {
                $subcats = get_categories('child_of='.$cat->term_id);
                if($subcats) {
                foreach( $subcats as $subcat )
                {  $subcategories[] = sanitize_title($subcat->name); }
                }
                }
                $subcats = array_unique($subcategories);
                if($subcats) {
                $subcats = implode(' ',$subcats);
                $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') );
               // echo '<li class="' . $subcats . '">';
    
                }
                ?>
                    <figure class="mix portfolio-item print">
                        <img class="img-responsive" src="<?php echo $url; ?>" alt="Portfolio Item">
                        <a href="<?php echo $url; ?>" title="Title Four" rel="portfolio" class="fancybox"><span class="plus"></span></a>
                        <figcaption class="mask">
                            <h3><?php the_title(); ?></h3>
                            <span><?php the_content(); ?></span>
                        </figcaption>
                    </figure>
    
    <?php endforeach ?>
    
  • 5.11 Years

    • Category : Html
    • Location : Mohali
    • Posted On : Dec 19, 2017

    This is another Client Side Validation strategy No JavaScript or jQuery required, Thanks to HTML5 in light of the fact that approvals should now be possible utilizing HTML5 without coding of javascript or any server side dialect, utilizing HTML5 you can approve frames with design, Forms must be approve either utilizing customer side or server side since it causes you to gather redress information or substantial shape esteems from the clients, you can't trust clients aimlessly, how about we see it.

    pattern="[A-Za-z] " accepts only capital or small letters. 
    <label>Name : (letters only)*</label>
    <input type="text" pattern="[A-Za-z] " title="only letters" required />
    
    pattern="[a-z0-9._% -] @[a-z0-9.-] \.[a-z]{2,4}$" accepts valid email address 
    <label>E-mail : (xyz@zyx.com)*</label>
    <input type="email" pattern="[a-z0-9._% -] @[a-z0-9.-] \.[a-z]{2,4}$" title="xyz@something.com" required />
    
    pattern="https?://. " required title="https://dorcode.com" accepts valid web url starting with http://. 
    <label>website : (https://dorcode.com)*</label>
    <input type="url"  pattern="https?://. " title="https://dorcode.com" required />
    
    pattern="[0-9] " accepts only numbers 0, 1, 2.... 
    <label>pin code : (numbers only)</label>
    <input type="text" pattern="[0-9] " title="numbers only" required />
    
    pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" accepts one number one upper and lower case letters with 8 or more chars. 
    <label>password : (at least 6 chars)</label>
    <input type="password" pattern=".{6,}" title="Six or more characters" required />
    
    pattern="^\d{10}$" accepts only numeric values with 10 digit. 
    <label>phone no : (10 chars)</label>
    <input type="tel" pattern="^\d{10}$" title="10 numeric characters only" required />
    
    pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{5,12}$" accepts alphanumeric values letters and digits.