jQuery: Select all options in a Multiple-option Select Box

Filed Under (General) by Wenbert on 04-02-2008

Tagged Under : , ,

Alright, here is a quick example of how to use jQuery to select all of the items in a multiple-option select box.

//Javascript part assuming that you have already included jquery.js in your header
$(document).ready(function() {
    $("#select_all_col_managers").click(function() {
        $("#col_manager_list").each(function(){
            $("#col_manager_list option").attr("selected","selected"); });
    }) ;

    $("#unselect_all_col_managers").click(function() {
        $("#col_manager_list").each(function(){
            $("#col_manager_list option").removeAttr("selected"); });
    }) ;

});

and now for the HTML part…

Filter by Collection Manager:
< select class="select_multiple" id="col_manager_list" multiple="multiple" name="RTCLMG[]">
< option>Must Select One
< option> value="< ?=$value['col_manager']?>">< ?=$value['col_manager']?>        < / select>

    < a href="#" id="select_all_col_managers">Select All< / a> 
    < a href=”#” id=”unselect_all_col_managers”>Unselect All< / a> 

Please note that I am using Code Igniter with this.

Why I hate Code Igniter (and why ZF FTW!)

Filed Under (General) by Wenbert on 01-02-2008

Tagged Under : ,

Here is a snippet from my code…

public function transaction($company_var=, $company_value=, $parent_var = , $parent_value=, $current_page=‘1′, $offset_value=)
    {
        $data = array();
        //GET VARIABLES PASSED THRU FUNCTION
        //I hate code igniter for this.
        //I found out that you can have query strings later on :-(
        //UPDATE:
        //But then again, Code Igniter sux at handling queries in the URL
        //I especially hate that you have to pass "variables" to the Method and not
        //being to get the variables directly from the URL using $_GET
        //WTF?!?! I have to enable query strings in the config file?
        //Did they just DISABLE a feature in PHP?
        //I AM NEVER GOING TO USE CODE IGNITER AGAIN. Zend Framework FTW!
        //I nevarrr had this problem in ZF! Zend Framwork FTW (again)
        $data[‘RTCO’]      = $company_value?$company_value:$_GET[‘RTCO’];  //Code Igniter is bullshit! I had to add this due to CI unable to $_GET properly!
        $data[‘RTPA8′]     = $parent_value?$parent_value:$_GET[‘RTPA8′];   //Code Igniter is bullshit! I had to add this due to CI unable to $_GET properly!

While in my other method, i have this…

redirect(‘?c=customer&m=transaction&RTCO=’.$company_value.‘&RTPA8=’.$parent_value.‘&col_manager_selected=’.$data[‘page’][‘col_manager_selected’]);
 

A Very Quick Zend Framework VS. Code Igniter Comparison

Filed Under (General) by Wenbert on 25-01-2008

Tagged Under : ,

Before anything else, I want the readers to know that I have used Zend Framework for a few months prior to using Code Igniter. I hang out in #zftalk (freenode) when I have time. So I am more of a ZF guy than a CI person. But after working with Code Igniter for a couple of weeks, I realized how much a love ZF over it (CI). Working and coding in ZF is more enjoyable than working in CI - I don’t know if it just me, but I don’t feel comfortable coding in Code Igniter.. I have had instances in CI where I think I could have done a better job if I wrote it in ZF - espcially with the ZF Components.

Code Igniter has some pretty nice features though. For instance, you can deploy an MVC project in less than a minute. You just have to configure the files an then viola! You are now up and running. While with ZF, you would have to make your own bootstrap file and you would have to choose which directory structure you will use. I think this is why a lot of people use CI. The learning curve is very easy and deployment is fast. But the joy ends there - well at least for me since I love exploring the unknown.

I have complete confidence that Zend Framework will be able to handle any project - from web sites to custom web applications — just about anything. It might take longer to configure and deploy, but in the end it is all worth it. I also find it very comforting that the Zend Framework Components are made by people who “really” know PHP. I have had bad experiences using “hacks”, poorly-tested user-contributed plug-ins by using other open-source ready-made CMSes.

In the end, both frameworks have their strengths and weakness. Code Igniter is fast to deploy and easy to configure. For Zend Framework, no matter what other people say about it– I love it :P FTW!

Getting started with: Zend Framework, symfony and CakePHP

Filed Under (General) by Wenbert on 14-10-2007

Tagged Under : , , , ,

This article was posted at IBM developerWorks a few days ago - I don’t know how I missed it. The article gets you started on three of the most popular PHP MVC Frameworks. Surprisingly, Code Igniter, which is my second option next to Zend Framework is not included in the article. Definitely as must read for anyone who is into MVC Development.

Here is a snippet:

There are several frameworks available for nearly every language. Selecting the right one for your needs can be somewhat difficult, especially if you haven’t used any of them before. While advice and opinions from colleagues and trusty developerWorks authors can be helpful in this area, there is really only one guiding principle that should be followed when selecting any framework: A framework is only as good as the amount of time and effort it saves everyone. A framework is no good if it works well for you but causes a significant increase in support calls. A framework is no good if it is easy to support, but hinders rather than assists your development. A framework is useless if it is elegant, but causes support and development issues.

When selecting a framework for your project, consider everyone involved, from the top down, and when you evaluate the framework, keep the impact to other parties in mind.

When you consider adopting a framework, look at your application closely and ask yourself it if needs a framework. A framework isn’t a necessity. Enterprise applications will continue to be written without the use of frameworks. Will a framework help you with the project? Will it save everyone time and effort? Will your application perform better on a framework? Will it provide the stability you are lacking? If the answer to any of these questions is yes, you should look to adopt a framework. If the answer to all of these questions is no, a framework will only complicate matters.

Unfortunately, size and scope restraints do not allow for a comprehensive coverage of all available PHP frameworks. This series focuses on three frameworks:

  • Zend Framework
  • symfony
  • CakePHP

These were selected based on a variety of factors, but might be best classified as “The One Your Boss Knows About,” “The One Someone Else Already Installed,” and “The One They’ve Been Talking About.” I encourage you to research CodeIgniter, Seagull, Web Application Component Toolkit (WACT), PRADO, Zoop, PHP on Trax, or any of the many other PHP frameworks available. Framework selection is very much a personal choice, much like selecting a language in which to code. This series isn’t going to tell you which framework is better, or worse, than the others. Where a framework does something well, it will be called out. Where a framework seems unwieldy, this will be called out, as well. Even if we are not comprehensive in our coverage of the myriad frameworks, the approach we take will help you weight the strengths and weaknesses of other frameworks. You need to form your own opinions about the frameworks being examined, which ones you like, and what you decide to pursue.

The Zend Framework

Everyone knows Zend — “The PHP Company.” When you download and install PHP, you’re downloading it from Zend and have been since around V3. In addition to distributing PHP, Zend Technologies has offered a wide range of PHP support technologies over the years. It should be no surprise that Zend offers a framework for PHP — a popular one at 2 million downloads to date. If your boss has heard of a PHP framework, the Zend Framework is likely to be the one.

symfony

Sponsored by Sensio, symfony “aims to speed up the creation and maintenance of Web applications, and to replace the repetitive coding tasks by power, control and pleasure.” The symfony framework has been used worldwide in a number of enterprise-level applications, perhaps most notably Askeet and Yahoo! Bookmarks. Odds are that if someone you know has installed, used, or played around with a PHP framework, that framework was symfony.

CakePHP

Borrowing heavily from Ruby on Rails, CakePHP aims to bring simplicity and scalability to PHP frameworks. Consistently recognized as a top PHP framework, CakePHP was recently selected as the core around which V5 of the Mambo Content Management System. Driven by a strong community and a rapidly growing user base, CakePHP’s popularity is growing steadily. If you’ve overheard a conversation about PHP frameworks, that conversation was probably about CakePHP.

Click here for the entire article.

Subscribe to Rss Feed : Rss