Jump to content
Fórum Script Brasil
  • 0

Cidade E Estado


Deividy

Question

7 answers to this question

Recommended Posts

  • 0

Tente isto dentro de um menu desdobrável:

<select size="1" name="estado">

<option value="4">

<option value="5">AC

<option value="6">AL

<option value="7">AM

<option value="30">AP

<option value="8">BA

<option value="9">CE

<option value="10">DF

<option value="11">ES

<option value="12">GO

<option value="13">MA

<option value="16">MG

<option value="15">MS

<option value="14">MT

<option value="17">PA

<option value="18">PB

<option value="20">PE

<option value="29">PI

<option value="19">PR

<option value="21">RJ

<option value="22">RN

<option value="24">RO

<option value="28">RR

<option value="23">RS

<option value="25">SC

<option value="27">SE

<option value="26">SP

<option value="31">TO</option>

</select>

Link to comment
Share on other sites

  • 0

Voce usa ASP... ??

Tenho um codigo aqui é meio grande.. bem da uma olhada.. tenta adaptar as suas necessidades...

Boa Sorte..

<HTML>

<HEAD>

<TITLE></TITLE>

<script>

function carregar(){

var url;

url = 'pagina.asp?uf='+document.form1.estado[document.form1.estado.selectedIndex].value;

document.form1.cidade.options.length = 0;

addItem(document.form1.cidade,"Aguarde...carregando","",false,document.form1.cidade.length)

myIframe.location = url;

}

function inicia(){

local = new Array();

var maximo, i, campo;

local = myIframe.a;

campo = document.form1.cidade;

local = myIframe.a;

maximo = local.length;

document.form1.cidade.options.length = 0;

for (i=0;i<maximo;i++){

addItem(campo,local[1],local[0],false,campo.length);

}

}

function addItem(obj,strText,strValue,blSel,intPos){

var newOpt,i,ArTemp,selIndex;

selIndex = (blSel)?intPos:obj.selectedIndex;

newOpt = new Option(strText,strValue);

Len = obj.options.length+1

if (intPos > Len) return

obj.options.length = Len

if (intPos != Len) {

ArTemp = new Array();

for(i=intPos;i<obj.options.length-1;i++)

ArTemp = Array(obj.options.text,obj.options.value);

for(i=intPos+1;i<Len;i++)

obj.options = new Option(ArTemp[i-1][0],ArTemp[i-1][1]);

}

obj.options[intPos] = newOpt;

if (selIndex > intPos)

obj.selectedIndex = selIndex+1;

else if (selIndex == intPos)

obj.selectedIndex = intPos;

}

</script>

</HEAD>

<BODY>

<div style="display: none; position: absolute;">

<iframe src="" name="myIframe" id="myIframe" width="100" height="100" marginwidth="0" marginheight="0">

</iframe>

</div>

<form name="form1" action="resposta.asp" method="post">

Escolha o Estado:

<select name="estado" onchange="carregar()">

<option value=""></option>

<option value="AC">AC - Acre</option>

<option value="AL">AL - Alagoas</option>

<option value="AM">AM - Amazonas</option>

<option value="AP">AP - Amapá</option>

<option value="BA">BA - Bahia</option>

<option value="CE">CE - Ceará</option>

<option value="DF">DF - Distrito Federal</option>

<option value="ES">ES - Espírito Santo</option>

<option value="GO">GO - Goiás</option>

<option value="MA">MA - Maranhão</option>

<option value="MG">MG - Minas Gerais</option>

<option value="MS">MS - Mato Grosso do Sul</option>

<option value="MT">MT - Mato Grosso</option>

<option value="PA">PA - Pará</option>

<option value="PB">PB - Paraíba</option>

<option value="PE">PE - Pernambuco</option>

<option value="PI">PI - Piauí</option>

<option value="PR">PR - Paraná</option>

<option value="RJ">RJ - Rio de Janeiro</option>

<option value="RN">RN - Rio Grande do Norte</option>

<option value="RO">RO - Rondônia</option>

<option value="RR">RR - Roraima</option>

<option value="RS">RS - Rio Grande do Sul</option>

<option value="SC">SC - Santa Catarina</option>

<option value="SE">SE - Sergipe</option>

<option value="SP">SP - São Paulo</option>

<option value="TO">TO - Tocantins</option>

</select><br>

Cidades:

<select name="cidade">

<option value="">____________________</option>

</select><br>

<Input type="submit" name"ok" value="Ok">

</form>

</BODY>

</HTML>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...