Posted By

fackz on 08/23/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fackz


combo estados brasileiros


 / Published in: PHP
 

para marcar um estado como selecionado: comboEstados(SP);

  1. function comboEstados($marcado = false){
  2. $montarArray = array("AC", "AL", "AM", "AP", "BA", "CE", "DF", "ES", "GO", "MA", "MG", "MS", "MT", "PA", "PB", "PE", "PI", "PR", "RJ", "RN", "RO", "RR", "RS", "SC", "SE", "SP", "TO");
  3. if ($marcado == ""){
  4. foreach($montarArray as $i){
  5. $resultArray .= "<option value=\"{$i}\">{$i}</option>";
  6. }
  7. return $resultArray;
  8. }else{
  9. foreach ($montarArray as $i){
  10. if ($marcado == $i){
  11. $resultArray .= "<option value=\"{$i}\" selected=\"selected\">{$i}</option>";
  12. }else{
  13. $resultArray .= "<option value=\"{$i}\">{$i}</option>";
  14. }
  15. }
  16. return $resultArray;
  17. }
  18. }

Report this snippet  

You need to login to post a comment.