Menus

Sunday 17 February 2019

Show/hide 'div' using JavaScript


Toggle between hiding and showing an element with JavaScript.


Add Html

<span class="label label-success" onclick="showDivtodo();">Show/Hide ToDo</span>
or using button
<button onclick="showDivtodo()">Show/Hide ToDo</button>     
<div  id="todo" style="display:none;">Show/Hide this text</div>
//Your code here..
</div>

Add JavaScript

function showDivtodo(){
      var x = document.getElementById("todo");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }        
    }


JavaScript Toggle (Hide/Show) an Element



Monday 11 February 2019

Yii2 Create span tag in DetailView widget



The span tag is like the div tag. It has no meaning at all and is mostly used for styling by using an id or class


Code Here

[
'attribute' => 'is_status',
        'format' => 'raw',
'value' => (($model->is_status == '1') ? '<span class="label label-success">Active</span>' :      '<span class="label label-danger">Deactive</span>' ),
],


Create url in DetailView widget

           

 [
             'attribute' => 'notice_file_path',
'format' => 'raw',
'value' =>  (!empty($model->notice_file_path) ? Html::a($model->notice_file_path, ['notice-file', 'nid' => $model->notice_id], $htmlOptions=["target"=>"_blank", 'data' => ['method' => 'post',]]) : " - ")
    ],




Saturday 5 January 2019

Replace First Occurrence of String With PHP


using preg_replace.

preg_replace — Perform a regular expression search and replace

mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [,int &$count ]] )


Example

preg_replace('/nothing/', 'something', $str, 1);

Example


<?php

$str="Dear Parent, Fee dues of Mr {V} is {V} on {V}";
echo $str ."<br>";
$c='Shaneesh';
$str= preg_replace("/{V}/", $c, $str, 1);
$str= preg_replace("/{V}/", '2500', $str, 1);
$str= preg_replace("/{V}/", '10-12-2019', $str, 1);
echo $str."<br>";

?>

Output

Dear Parent, Fee dues of Mr {V} is {V} on {V}
Dear Parent, Fee dues of Mr Shaneesh is 2500 on 10-12-2019




Thursday 20 December 2018

Calculating Age from Birthdate


Calculate age from given birthdate


How to Calculate Age from Date of Birth in PHP



<?php

$dateOfBirth = "21-12-1983";
$today = date("Y-m-d");
$diff = date_diff(date_create($dateOfBirth), date_create($today));
echo 'Age is '.$diff->format('%y');

?>




VB6 Code

Function Age (varBirthDate As Variant) As Integer 

 Dim varAge As Variant 

 If IsNull(varBirthdate) then Age = 0: Exit Function 

 varAge = DateDiff("yyyy", varBirthDate, Now) 
 If Date < DateSerial(Year(Now), Month(varBirthDate), _ 
 Day(varBirthDate)) Then 
 varAge = varAge - 1 
 End If 
 Age = CInt(varAge) 

 End Function





Wednesday 19 September 2018

Forcefully Close a Program in Ubuntu


How to close a program from the terminal in ubuntu


  1. The program name with:
    pkill <name_of_program>
    
  2. use of program PID (process id)
    • kill it with kill <PID>

Steps for close program

1. open a Terminal window

2. To view a list of running processes, enter the following text at the prompt and press Enter.
$ ps -A

eg : pkill filezilla   - use program name.


To kill a process using its PID, enter the “killall” command (without the quotes) at the prompt, followed by a space, and then the corresponding PID from the generated list. Press Enter.






Tuesday 19 June 2018

How to play audio and video files in the background on Android


How to set play mx player in the background  on android mobile



Open your mobile


Just launch MX Player app and then press the menu icon at the top-right side of the screen.


Go to choose "Play".    or  (Go to “Settings” and then choose “Player”.)

Check the box next to “Background Play"  


How to enable background play. 






Saturday 24 February 2018

Always On Top for YouTube Video in Google Chrome


First select Google Chrome Settings and click to Extension menu.

Check Extension for app Always On Top for YouTube.







Launch icon your browser.




Click this icon and show your video always on top.





Thank You