Create Remove Iframe At Time

create iframe with src in table > td#marker


        function removeIframe(){
            if(document.getElementById('notif-to-user')){
                var frame = document.getElementById("notif-to-user");
                frame.parentNode.removeChild(frame);
            }
        }

        function createIframe(){
            if(!document.getElementById('notif-to-user')){
                var ifrm = document.createElement('iframe');
                ifrm.setAttribute('id', 'notif-to-user');
                ifrm.setAttribute('src', 'http://mygoddamn.link');
                var el = document.getElementById('marker');
                el.parentNode.insertBefore(ifrm, el);
            }
        }

        window.setInterval(function(){
            var date = new Date();
            // jika lebih dari jam 12 iframe di hapus
            if(date.getHours() > 1){
                removeIframe();
            }
            // jika jam 1 lebih 1 menit iframe di buat
            if(date.getHours() === 1 && date.getMinutes() === 1){
                createIframe();
            }
            // jika jam 1 lebih 59 menit (jam 2) iframe di hapus
            if(date.getHours() === 1 && date.getMinutes() === 59){
                removeIframe();
            }
            // jalan tiap 5 detik
        }, 5000);
    
Advertisements

Creating a Template Helper for CodeIgniter

first you create /helper/template_helper

<?php if (! function_exists('renderPage')) { 	
function renderPage($view, $data){ 		        
         $CI =& get_instance(); 		
         $CI->load->view('t/header', $data);
         $CI->load->view($view, $data);
         $CI->load->view('t/footer');
	}
}

then in controller you can call function like this

function index(){
  $this->load->helper('template');
  $data['name_title'] = 'Title Page In Head Tag';
  renderPage('index_view',$data);
}

source: http://varun1505.com/blog/2013/09/01/creating-a-template-helper-for-codeigniter/

Selected on Dropdown Select PHP

<select name=”kategori” id=””>
<option value=””> — Pilih Kategori –</option>
<?php
foreach ($categ as $c) {
if ($c->kategori == $u->kategori) {$select = ‘selected=”selected”‘;
} else { $select = ”;}
echo “<option value=\”{$c->kategori}\” {$select}>{$c->kategori}</option>”;
}
?>
</select>