Top Questions

  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jul 28, 2016

    simple php rating in php

    <?php
    require "user/class.user.php";
    $auth_user = new USER();
    /********PDO Code***********/
    $email='user@gmail.com';
    $user=$auth_user->runQuery("SELECT * FROM login where email=:email");
    $user->execute(array(':email'=>$email));
    $userdatasingle=$user->fetchAll();
    $userdatasingle=$userdatasingle[0];
    ?>
    /*****HTML*******/
    <div class="rating">
                          
     <input type="hidden" name="rating" id="rating" value="<?php echo $userdatasingle["rating"]; ?>" />
           <ul onMouseOut="resetRating(<?php echo $userdatasingle["id"]; ?>);">
                 <?php
                 for($i=1;$i<=5;$i  ) {
                 $selected = "";
                 if(!empty($userdatasingle["rating"]) && $i<=$userdatasingle["rating"]) {
                 $selected = "selecteds";
                 }
         ?>
      <li class='<?php echo $selected; ?>' onmouseover="highlightStar(this,<?php echo $userdatasingle["id"]; ?>);" onmouseout="removeHighlight(<?php echo $userdatasingle["id"]; ?>);" onClick="addRating(this,<?php echo $userdatasingle["id"]; ?>);">&#9733;</li>  
                            <?php }  ?>
                        <ul>
                        <span class="ratings"><a href="#" class="Lgreen-txt font-6 rat-txt"><?php echo $userdatasingle["rating"]; ?> anmeldelser</a>
                       </span>
    </div> 
    /***********Script*************/
    <script>
    function highlightStar(obj,id) {
      removeHighlight(id);    
      $('.rating li').each(function(index) {
        $(this).addClass('highlights');
        if(index == $('.rating li').index(obj)) {
          return false; 
        }
      });
    }
    
    function removeHighlight(id) {
      $('.rating li').removeClass('selecteds');
      $('.rating li').removeClass('highlights');
    }
    
    function addRating(obj,id) {
      $('.rating li').each(function(index) {
        $(this).addClass('selecteds');
        $('#rating').val((index 1));
        if(index == $('.rating li').index(obj)) {
          return false; 
        }
      });
      $.ajax({
      url: "add_rating.php",
      data:'id=' id '&rate=' $('#rating').val(),
      type: "POST",
      success: function(data) {
      $(".rating").load(location.href " .rating>*","");
      }
      });
    }
    
    function resetRating(id) {
      if($('#rating').val() != 0) {
        $('.rating li').each(function(index) {
          $(this).addClass('selecteds');
          if((index 1) == $('#rating').val()) {
            return false; 
          }
        });
      }
    } 
    </script>
    /**********AJAX File*************/
    require "user/class.user.php";
    $auth_user = new USER();
    
    if (isset($_POST['rate']) && !empty($_POST['rate'])) {
     
        $rate = $_POST['rate'];
        $id = $_POST['id'];
    // check if user has already rated
        $sql = $auth_user->runQuery("UPDATE `login` SET rating=:rating WHERE `id`=:id");
       $sql->execute(array(':id'=>$id,':rating'=>$rate));
       
    }
     
  • 5.11 Years

    • Category : Java
    • Location : Mohali
    • Posted On : Jul 9, 2016

    URL — The new history entry's URL is given by this parameter. Note that the browser won't attempt to load this URL after a call to pushState(), but it might attempt to load the URL later, for instance after the user restarts the browser. The new URL does not need to be absolute; if it's relative, it's resolved relative to the current URL. The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception. This parameter is optional; if it isn't specified, it's set to the document's current URL.

    // modify history
    window.history.pushState(obj, title, url);
    window.history.pushState("", "", 'www.dorcode.com');  
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Jun 25, 2016

    you can make td editable using this code

    Note: Add Table Class editableTable
    <script>
    $(function () {
        $(".qty").dblclick(function () {
            var OriginalContent = $(this).text();
            var Originalid = $(this).attr('id');
            $(this).addClass("cellEditing");
              $(this).html("<input type='text' class='qty' value='"   OriginalContent   "' />");
            $(this).children().first().focus();
            $(this).children().first().focusout(function (e) {
                    var newContent = $(this).val();
                    $(this).parent().text(newContent);
                    $(this).parent().removeClass("cellEditing");
            });
             
        $(this).children().first().blur(function(){
            $(this).parent().text(OriginalContent);
            $(this).parent().removeClass("cellEditing");
        });
        });
    });
     </script>
  • 2.9 Years

    • Category : Ajax
    • Location : Chandigarh
    • Posted On : Jun 23, 2016

    if you want to refresh single div not a page than you can use this code

    <div class="avlfrom">
     <span class="leftgap">
    <a  href="javascript:void(0);"  class="remove_field" id="1">delete</a>
    <a  href="javascript:void(0);"  class="remove_field" id="2">delete</a>
    <a  href="javascript:void(0);"  class="remove_field" id="3">delete</a>
    </span>
    </div>
    <script>
           $(document).on('click','.remove_field',function(){
            if (confirm("Are you sure you want to delete")) {
                   var id=$(this).attr('id');
                   $.ajax({
           url: "ajax_page.php",            
                 type: "POST",
                       data: 'id=' id,
                 success: function(data) {
                              $(".avlfrom").load(location.href " .avlfrom>*","");
          },
           }); 
       return false;
                    }
                 });
    
    <script>
  • 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 : Jquery
    • Location : Chandigarh
    • Posted On : Mar 22, 2016

    You can Create textarea into a rich content/text editor using jQuery.

    /***Footer part***/
    <script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script>
    <script type="text/javascript">
            bkLib.onDomLoaded(function() { nicEditors.allTextAreas() }); // convert all text areas to rich text editor on that page
    
            bkLib.onDomLoaded(function() {
                 new nicEditor().panelInstance('area1');
            }); // convert text area with id area1 to rich text editor.
    
            bkLib.onDomLoaded(function() {
                 new nicEditor({fullPanel : true}).panelInstance('area2');
            }); // convert text area with id area2 to rich text editor with full panel.
    </script>
    /***HTML PART***/
    <!DOCTYPE html>
    <html>
    <head>
      <title>How to Create textarea into a rich content/text editor using jQuery</title>  
     
      <script type="text/javascript">
    //<![CDATA[
      bkLib.onDomLoaded(function() {
            new nicEditor({maxHeight : 200}).panelInstance('area');
            new nicEditor({fullPanel : true,maxHeight : 200}).panelInstance('area1');
      });
      //]]>
      </script>
    </head>
    <body>
    <h4>How to Create textarea into a rich content/text editor using jQuery</h4>
    <div id="sample">
      <h4>Simple textarea</h4>  
      <textarea name="area" id="area" style="width:70%;height:200px;">
           Some Initial Content was in this textarea
      </textarea>
      <h4>textarea with complete panel</h4>
      <textarea name="area1" id="area1" style="width:70%;height:200px;">
           Some Initial Content was in this textarea
      </textarea>
    </div>
    </body>
    </html>
  • 2.9 Years

    • Category : Html
    • Location : Chandigarh
    • Posted On : Mar 10, 2016
    <html>
    <head>
    <style>
      .js div#preloader { position: fixed; left: 0; top: 0; z-index:99999; width: 100%; height: 100%; overflow: visible; background:#FFFFFF url('images/load.gif') no-repeat center center;background-size:30%;}
    .ui-loader.ui-corner-all.ui-body-a.ui-loader-default {display: none;}
      </style>
    </head>
     <div class="js">
    <body>
    <div id="preloader"></div> 
    </body>
    </div>
    </html>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    /*====================================================== start */
    
    
    jQuery(document).ready(function($) {  
    
    // site preloader -- also uncomment the div in the header and the css style for #preloader
    $(window).load(function(){
      $('#preloader').fadeOut('10000',function(){$(this).remove();});
    });
    });
    /*====================================================== end */
    </script>

     

  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Feb 25, 2016
    $(function(){
        // this will get the full URL at the address bar
        var url = window.location.href; 
        // passes on every "a" tag 
        $(".main-nav li a").each(function() {
                // checks if its the same on the address bar
            if(url == (this.href)) { 
                $(this).closest("li").addClass("current");
            }
        });
    });

     

  • 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 : Php
    • Location : Chandigarh
    • Posted On : Dec 23, 2015
    <form action="" method="post" enctype="multipart/form-data" class="upload_bus"> 
    div class="btn-group col-lg-3 col-md-3 col-sm-6 col-xs-12 rightgp-btns">
      <input class="create-doc" id="upbuss"  type="file" name="upbus" >
    </div>
    </form>
    <center><div id="loader-icon" style="display:none;"><img src="images/loader-time.gif" height="100px" width="100px" /></div></center>
    <script>
    $('input#upbill').change(function(){
    $('form.upload_b').submit();
    })
    $('form.upload_b').submit(function(e){
      var formData = new FormData(this);
      $('#loader-icon').show();
    $.ajax({
    url: "upload_file.php",            
    type: "POST",
    data:  formData,
    mimeType:"multipart/form-data",
    contentType: false,
    cache: false,
    processData:false,
    success: function(data)
    {
      $('#loader-icon').hide();
       window.location.href="example.php";
    }
    });
    return false;
    });
    </script>