Search This Blog

Wednesday, 28 August 2024

Bouncing ball animation with CSS

HTML:
<div class="ball"></div>


CSS:

        .ball {
            width: 25px;
            height: 25px;
            background-color: #61dafb;
            border-radius: 50%;
            position: relative;
            animation: bounce 2s infinite ease-in-out;
        }
        
        @keyframes bounce {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-100px);
            }
        }



Create a perfect circle with CSS

HTML:

 <div class="circle"></div>


CSS:

.circle { 

      width: 250px

      height: 250px

      background-color: #e74c3c

      border-radius: 50%

}

Tuesday, 27 August 2024

Finding Minimum and Maximum Values Using the JavaScript reduce Function

You can find the minimum and maximum values in an array using the JavaScript reduce function by iterating through the array and keeping track of the minimum and maximum values encountered. 

reduce function: Iterates through each element of the array, maintaining an accumulator (acc) which, in this case, is an object that holds both the minimum and maximum values.

Here's how you can do it:

Example:

----------------------------------------------------------------------

const numbers = [3, 5, 1, 8, 2, 10]; 

const result = numbers.reduce((acc, current) =>

  return { 

      min: current < acc.min ? current : acc.min

      max: current > acc.max ? current : acc.max 

 }; 

}, { min: Infinity, max: -Infinity }); 

  console.log(`Min: ${result.min}, Max: ${result.max}`);

----------------------------------------------------------------------

Monday, 10 August 2020

Bootstrap zipcode validation for country US and Canada

----------------------------------------------------------------------------------------------

$('#formID').bootstrapValidator({

       feedbackIcons: {

           valid: 'glyphicon glyphicon-ok',

           invalid: 'glyphicon glyphicon-remove',

           validating: 'glyphicon glyphicon-refresh'

       },

       fields: {

           InputZip: {

               validators: {

               callback: {

                        message: 'The zip is not valid postal code',

                        callback: function (value, validator, $field) {

                        var country = $("#InputCountry").val();                      

                        switch (country) {

                            case 'CA':

                                return /^(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}\s?[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}[0-9]{1}$/i.test(value);

                            case 'US':

                            default:

                                return /^\d{4,5}([\-]\d{4})?$/.test(value);

                        }

                        }

                    }

               }

           }

          

       }

   });

----------------------------------------------------------------------------------------------

Sunday, 9 August 2020

Kendo Grid - Add tooltip to Kendo Grid Header

       

 ----------------------------------------------------------------------

     var gridName = "myKendoGridID";

      $("#"+gridName+" thead tr th").each(function(e){
$(this).attr('title', $(this).text());
      });

----------------------------------------------------------------------

Monday, 4 March 2013

Change cell value in jqGrid


To change the value of a cell in a jqGrid, you can use the setCell method provided by jqGrid. 
Here’s how you can do it:

Syntax:

$("#grid").jqGrid('setCell', rowid, columnname, value, cssclass, properties)

Parameters:

  • rowid: The ID of the row where the cell is located.
  • columnname: The name of the column (the name property from the colModel).
  • value: The new value to set in the cell.
  • cssclass: (Optional) A class to apply to the cell.
  • properties: (Optional) An object containing any additional properties to set on the cell.

  • Examples:
    ----- ---------- ---------- ---------- ---------- ---------- ----------
        
         $("#gridId").jqGrid('setCell', rowId,'qty', '12345');          

    ----- ---------- ---------- ---------- ---------- ---------- ----------
                                                OR
    ----- ---------- ---------- ---------- ---------- ---------- ----------
     
        var rowData = $('#gridId').jqGrid('getRowData', rowId);
        rowData.qty = '12321';
        $('#gridId').jqGrid('setRowData', rowId, rowData);

    ----- ---------- ---------- ---------- ---------- ---------- ----------

    Change JqGrid Row Color


     $("#rowId").css("background","#FFEAEA");
     $("#rowId").css("color", "black");