Tuesday, 20 December 2016

How do i set profile image as first letters of first and last name




HTML

<span id="firstName">Hemant</span>
<span id="lastName">Vishwakarma</span>
<div id="profileImage"></div>

CSS

#profileImage {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: #512DA8;
  font-size: 35px;
  color: #fff;
  text-align: center;
  line-height: 150px;
  margin: 20px 0;
  font-family:Verdana, Geneva, sans-serif;
}


JS

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

<script>
$(document).ready(function(){
  var firstName = $('#firstName').text();
  var lastName = $('#lastName').text();
  var intials = $('#firstName').text().charAt(0) + $('#lastName').text().charAt(0);
  var profileImage = $('#profileImage').text(intials);
});
</script>

How do i set profile image as first letters of first and last name

Monday, 19 December 2016

Add & Remove Input Fields Dynamically with jQuery




<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Add/Remove Input Fields Dynamically with jQuery</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>

<body>
    <div class="input_fields_wrap" style="margin-left:25%; margin-top:10%;">
        <button class="add_field_button">Add More Fields</button>
        <div><input type="text" name="mytext[]"></div>
    </div>
    <script>
        $(document).ready(function() {
            var max_fields = 10; //maximum input boxes allowed
            var wrapper = $(".input_fields_wrap"); //Fields wrapper
            var add_button = $(".add_field_button"); //Add button ID

            var x = 1; //initlal text box count
            $(add_button).click(function(e) { //on add input button click
                e.preventDefault();
                if (x < max_fields) { //max input box allowed
                    x++; //text box increment
                    $(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
                }
            });

            $(wrapper).on("click", ".remove_field", function(e) { //user click on remove text
                e.preventDefault();
                $(this).parent('div').remove();
                x--;
            })
        });
    </script>
</body>
</html>

Add & Remove Input Fields Dynamically with jQuery

Sunday, 18 December 2016

Yii2 Framework findBySql

Yii2 findBySql

Sample 1
    $sql = 'SELECT * FROM tbl_user';
   $model = User::findBySql($sql)->all();

Sample 2
  $sql = 'SELECT * FROM tbl_user';
  $model = User::findBySql($sql)->one();



Yii2 Framework findBySql