function form_select($label, $name, $option_array, $value = NULL) { $out = ' <label>' . $label . '</label><select name="' . $name . '">'; foreach ($options_array as $item_label->{$item_value}) { $out .= ' <option value=' . $item_value . ' ' . form_selected($item_value, $value) . '>' . $item_label . '</option>'; } $out .= '</select>'; return $out; }
function selected_options($value, $array, $options = NULL) { if ($options['csv_list'] == 1) { $value_array = explode(",", $value); foreach ($value_array as $i) { $set_value_array[$i] = TRUE; unset($set_value_array[0]); } print_r($set_value_array); #die(); } #print_r($array); foreach ($array as $key => $value) { $value_options .= '<option value="' . $key . '" ' . form_selected($value, $set_value_array[$key]) . '>' . $value . '</option>'; } return $value_options; }
<?php global $db; $sql = 'select * from groups where parent_KEY = "' . SALSA_GROUP_LIST_PARENT . '"'; echo $sql; $S = $db->Execute($sql) or die($db->errorMsg()); $s = $S->GetArray(); unset($list_options); if ($_REQUEST['ex']['List'][0]) { $list_selected = $_REQUEST['ex']['List'][0]; } foreach ($s as $i) { $list_options .= '<option value="' . $i['groups_KEY'] . '" ' . form_selected($i['groups_KEY'], $list_selected) . ' >' . $i['Group_Name'] . '</option>'; } echo $list_options;
<?php $sql = 'select * from campaign order by Reference_Name asc'; $C = $db->CacheExecute($sql) or die($sql . $db->errorMsg()); $c = $C->GetArray(); foreach ($c as $i) { $campaign_object_array[$i['campaign_KEY']] = $i['Reference_Name']; } foreach ($campaign_object_array as $ab => $name) { $campaign_object_options .= '<option value="' . $ab . '" ' . form_selected($ab, $campaign_value) . '>' . $name . '</option>'; } echo $campaign_object_options;
<?php $company_type_array = array("Organization" => "Organization", "Company" => "Company", "Foundation" => "Foundation", "Media Outlet" => "Media Outlet", "Vendor" => "Vendor", "Other" => "Other"); foreach ($company_type_array as $ab => $name) { $company_options .= '<option value="' . $ab . '" ' . form_selected($ab, $o['Name']) . '>' . $name . '</option>'; } echo $company_options;
<?php $campaigns_array = array('GFC' => 'GFC', 'RAG' => 'RAG', 'RFP' => 'RFP', 'Comms' => 'Comms', 'Online' => 'Online', 'Devo' => 'Devo'); $source_campaign_options = '<option value=""></option>'; foreach ($campaigns_array as $ab => $name) { $source_campaign_options .= '<option value="' . $ab . '" ' . form_selected($ab, $s['source_campaign']) . '>' . $name . '</option>'; } echo $source_campaign_options;
<?php $state_list = array('AL' => "Alabama", 'AK' => "Alaska", 'AZ' => "Arizona", 'AR' => "Arkansas", 'CA' => "California", 'CO' => "Colorado", 'CT' => "Connecticut", 'DE' => "Delaware", 'DC' => "District Of Columbia", 'FL' => "Florida", 'GA' => "Georgia", 'HI' => "Hawaii", 'ID' => "Idaho", 'IL' => "Illinois", 'IN' => "Indiana", 'IA' => "Iowa", 'KS' => "Kansas", 'KY' => "Kentucky", 'LA' => "Louisiana", 'ME' => "Maine", 'MD' => "Maryland", 'MA' => "Massachusetts", 'MI' => "Michigan", 'MN' => "Minnesota", 'MS' => "Mississippi", 'MO' => "Missouri", 'MT' => "Montana", 'NE' => "Nebraska", 'NV' => "Nevada", 'NH' => "New Hampshire", 'NJ' => "New Jersey", 'NM' => "New Mexico", 'NY' => "New York", 'NC' => "North Carolina", 'ND' => "North Dakota", 'OH' => "Ohio", 'OK' => "Oklahoma", 'OR' => "Oregon", 'PA' => "Pennsylvania", 'RI' => "Rhode Island", 'SC' => "South Carolina", 'SD' => "South Dakota", 'TN' => "Tennessee", 'TX' => "Texas", 'UT' => "Utah", 'VT' => "Vermont", 'VA' => "Virginia", 'WA' => "Washington", 'WV' => "West Virginia", 'WI' => "Wisconsin", 'WY' => "Wyoming", "AB" => "Alberta", "BC" => "British Columbia", "MB" => "Manitoba", "NF" => "Newfoundland", "NB" => "New Brunswick", "NS" => "Nova Scotia", "NT" => "Northwest Territories", "NU" => "Nunavut", "ON" => "Ontario", "PE" => "Prince Edward Island", "QC" => "Quebec", "SK" => "Saskatchewan", "YT" => "Yukon Territory", "ot" => "Other"); $state_options = '<option value="">Select a state</option>'; foreach ($state_list as $ab => $name) { $state_options .= '<option value="' . $ab . '" ' . form_selected($ab, $s['State']) . '>' . $name . '</option>'; } echo $state_options;