Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Array to Create State Dropdown List - Need to set specific state to default
    primarykey
    data
    text
    <p>I have a plugin that I am using that creates a dropdown of the US states using an array and then a loop to populate a select box. Here is the array</p> <pre><code>//Define the US State Array to be used to generate the STATE select box $usStates = array( "AL" =&gt; "Alabama", "AK" =&gt; "Alaska", "AZ" =&gt; "Arizona", "AR" =&gt; "Arkansas", "CA" =&gt; "California", "CO" =&gt; "Colorado", "CT" =&gt; "Connecticut", "DE" =&gt; "Delaware", "FL" =&gt; "Florida", "GA" =&gt; "Georgia", "HI" =&gt; "Hawaii", "ID" =&gt; "Idaho", "IL" =&gt; "Illinois", "IN" =&gt; "Indiana", "IA" =&gt; "Iowa", "KS" =&gt; "Kansas", "KY" =&gt; "Kentucky", "LA" =&gt; "Louisiana", "ME" =&gt; "Maine", "MD" =&gt; "Maryland", "MA" =&gt; "Massachusetts", "MI" =&gt; "Michigan", "MN" =&gt; "Minnesota", "MS" =&gt; "Mississippi", "MO" =&gt; "Missouri", "MT" =&gt; "Montana", "NE" =&gt; "Nebraska", "NV" =&gt; "Nevada", "NH" =&gt; "New Hampshire", "NJ" =&gt; "New Jersey", "NM" =&gt; "New Mexico", "NY" =&gt; "New York", "NC" =&gt; "North Carolina", "ND" =&gt; "North Dakota", "OH" =&gt; "Ohio", "OK" =&gt; "Oklahoma", "OR" =&gt; "Oregon", "PA" =&gt; "Pennsylvania", "RI" =&gt; "Rhode Island", "SC" =&gt; "South Carolina", "SD" =&gt; "South Dakota", "TN" =&gt; "Tennessee", "TX" =&gt; "Texas", "UT" =&gt; "Utah", "VT" =&gt; "Vermont", "VA" =&gt; "Virginia", "WA" =&gt; "Washington", "WV" =&gt; "West Virginia", "WI" =&gt; "Wisconsin", "WY" =&gt; "Wyoming" ); </code></pre> <p>And the loop...</p> <pre><code>//Loop through the state array to build the state select box foreach( $usStates as $key =&gt; $value ) { $selected = ""; if($_POST['orderState'] == $key) $selected = "selected"; $wpgft_post_content .= '&lt;option value="'.$key.'" ' . $selected . '&gt;'. $value .'&lt;/option&gt;'; } $wpgft_post_content .='&lt;/select&gt;'; if($error_state) $wpgft_post_content .='&lt;br /&gt;&lt;span class="wpgft_error"&gt;'.$error_state.'&lt;/span&gt;&lt;/dd&gt;'; } else { $wpgft_post_content .='&lt;dt&gt;State / Province / Region:&lt;/dt&gt;'; $wpgft_post_content .= '&lt;select name="orderState"'.$ro.'&gt;'; </code></pre> <p>If I need to set Colorado as the default state, where/how do I do this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload