Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

PHP State-Array Generator

Simple array for HTML mockups.

function state_selection() {
        echo '<select name="state">';
                $states = array(
                        'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
                );
                foreach ($states as $state_name) {
                        echo '<option value="'.$state_name.'">'.$state_name.'</option>';
                }
        echo '</select>';
}
state_selection();

Active Selection Box (drop down) examples

// description of your code here

<%= select_tag( :saction, options_for_select([["Actions:",0],["Edit",1],["Delete",2]],0),
                                :onchange => "if(confirm('Are you sure?  This will effect all products checked below.')) products_form.submit(); else products_form.saction.value = 0;")%>


<%= select_tag( :sort_by, options_for_select([["Sort by:",0],["Name",'name'],["Price",'price'], ["Date Listed",'id']],0),
                                :onchange => remote_function(        :with => "'sort_by='+$(\"sort_by\").value",
                                                                                                :loading => "false;",
:url => { :controller => 'products', :action => :change_order } )
)  %>
« Newer Snippets
Older Snippets »
2 total  XML / RSS feed