eKini: Web Developer Blog

PHP, MySQL, Javascript, MVC, Zend Framework, AJAX, jQuery

The 6 Most Important CSS You Need To Know

March31

Everyone should read this.

posted under General | No Comments »

Get name of textarea or input using jQuery

March28

You can do this in jQuery:

  1.  
  2. $("textarea[@name=my_field_name]").val()
  3. $("input[@name=my_field_name]").val()
posted under General | 2 Comments »

Check Multiple Checkboxes in one click using jQuery

March24

This is useful if you want to “delete” or “update” multiple rows in a table at the same time. This works like the “Check All Email” in YahooMail.

  1.  
  2. $(document).ready(function() {
  3.     //check all checkboxes
  4.     $("#check_all_boxes").click(function() {
  5.         $(".mycheckbox").each(function(i){
  6.             $(this).attr("checked","checked");
  7.         });
  8.     });
  9.  
  10.     //uncheck all checkboxes
  11.     $("#uncheck_all_boxes").click(function() {
  12.         $(".mycheckbox").each(function(i){
  13.             $(this).removeAttr("checked");
  14.         });
  15.     });
  16.  
  17.     //reset the search form
  18.     $("#reset_button").click(function() {
  19.         $("#search_form input").each(function(i) {
  20.             //alert($(this).html());
  21.  
  22.         });
  23.     });
  24.  
  25. });

And the HTML Code is:

< input class="mycheckbox" name="a" value="1" type="checkbox" />Number 1
< input class="mycheckbox" name="b" value="1" type="checkbox" />Number 2
< input class="mycheckbox" name="c" value="1" type="checkbox" />Number 3
< a href="#" id="#check_all_boxes">Check All< / a>
< a href="#" id="#uncheck_all_boxes">Uncheck All< / a>
posted under General | No Comments »

How to do AJAX in jQuery with JSON callback in Zend Framework

March20

Here is how to do it in Zend Framework.
Let’s start with the form:

  1.  
  2. <textarea id="mytext">
  3. </textarea>
  4. <input type="button" id="mybutton" value="go" />
  5.  
  6. < script language="Javascript">
  7. //jQuery stuff    
  8. $(document).ready(function() {
  9.     $("#mybutton").click(function() {
  10.         $.post("< ?=$this->baseUrl?>/path/to/my/coolaction",{
  11.             mytext: $(‘#mytext’).val()
  12.         }, function(data){
  13.             //alert("Data Loaded: " + data);
  14.             obj = window.eval(data);
  15.             alert("Saved: "+obj[‘mytext’]);
  16.         },"json");
  17.     });
  18. });
  19. < / script>
  20.  

In your controller-action:

  1.  
  2. public function coolAction()
  3. {
  4.      try {
  5.           if ($this->_request->isPost()) {
  6.                  //Do something that will save the $_POST to the database here.
  7.                  $json = Zend_Json::encode($_POST);
  8.                  echo $json;
  9.           } else {
  10.                  throw new Exception ("Invalid action. Not post");
  11.           }
  12.      } catch (Exception $e) {
  13.             echo $e->getMessage();
  14.      }
  15.  
  16. }
  17.  
posted under General | 2 Comments »

Zend_View Placeholders by Matthew Weier O`Phinney

March19

In his blog post, he used something that I didn’t know or hear about — headLink() and headScript(). So I went ahead to add a comment and asked for an example. Then I got it — he has a new post on how to use Zend_View placeholders.

/me gives free beer to Matthew.

posted under General | No Comments »

How to do a Select statement inside the main select statement in MySQL

March18

A little bit slow but it gets the job done. I used this to generate a report to get the total open_amount for customers.

  1.  
  2.     SELECT
  3.     s.parent_no,
  4.     s.parent_name,
  5.     t.parent_no,
  6.     t.col_manager,
  7.     t.invoice_date,
  8.     t.due_date,
  9.     t.over_7_date,
  10.     t.over_7_by_eom,
  11.     t.open_amount,
  12.  
  13.     (SELECT SUM(t2.open_amount) FROM transactions t2
  14.         WHERE
  15.         (t2.parent_no=t.parent_no)
  16.         AND t2.trans_status = ‘open’) AS total
  17.        
  18.     FROM
  19.     transactions t
  20.     LEFT JOIN summary s ON s.parent_no = t.parent_no
  21.     WHERE
  22.     ( t.col_manager=‘aaa’ OR
  23.     t.col_manager = ‘bbb’  OR
  24.     t.col_manager = ‘ccc’  OR
  25.     t.col_manager = ‘ddd’  OR
  26.     t.col_manager = ‘eee’  OR
  27.     t.col_manager = ‘fff’  )
  28.     AND t.trans_status = ‘open’ ORDER BY s.parent_name ASC
  29.  
posted under General | No Comments »

Zend Framework 1.5 RELEASED!

March18

To people who don’t use Zend Framework, seriously, this is the time for you to switch. I need not say more. Just head on the their newly-skinned site: http://framework.zend.com

And they have something that every new-comer wants, a Zend Framework Quickstart Tutorial!!!!!

Anyone from Cebu who wants to go out for the weekend and celebrate the release of ZF 1.5? I’m buying the beer!

posted under General | 3 Comments »

Zend Framework: Slides - Builing Rich Internet Applications in 3 days

March14

Here are the slides.

Wil Sinclair has been a busy man of late. In addition to getting ready for the 1.5 release of Zend Framework and recording a podcast with me, he has taken the time to present 2 different presentations on Zend Framework.

posted under General | No Comments »

What Zend_Layout looks like. An overview. Code sample. No explanation :P

March10

I wrote this for myself instead of for other people. The short code example is found on my wiki (http://wiki.ekini.net/main/Zend_Layout).

Basically it is a very quick overview of Zend_Layout — more like a cheatsheet (again). The bootstrap, the directory structure and then the controller and view part. It is based on Akrabat`s Zend_Layout Tutorial.

posted under General | 3 Comments »

Acid3 results for common browsers

March10

here are the results.

Safari has done good. Firefox and Opera too…

posted under General | No Comments »
« Older Entries