Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera peguei aqui nesse forum mesmo um codigo para atualizar o combo de acordo com a opção selecionada em outro combo:
Exemplificando
Regiões
-----------
Sudeste
Sul
Nordeste
[selecionado opção Sudeste]
No outro combo aparece
Estados
--------------
SP
RJ
MG
etc
se seleciona "Sul"
Estados
--------------
RS
PR
SC
Assim sucessivamente...............................
Meu codigo que peguei aqui a um tempo, que funciona é:
Remote.asp (Usuário não ve)
<% dbConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\database\banco.mdb;" SQL1 = "SELECT * FROM subcategorias WHERE categoria = "&request.querystring("cat")& " ORDER BY subcategoria" set rs1 = server.CreateObject("ADODB.Recordset") rs1.CursorType = 3 rs1.Open SQL1, dbConn rs1.MoveFirst response.Write sql1%><script> loc = new Array(<%=rs1.recordcount%>) for (i=0; i < <%=rs1.recordcount%>; i++) { loc[i] = new Array(2) for (j=0; j < 2; j++) { loc[i][j] = "0" } } <% j = 0 do while not rs1.eof%> loc[<%=j%>][0] = "<%=trim(rs1("codigo"))%>"; loc[<%=j%>][1] = "<%=trim(rs1("subcategoria"))%>"; <% rs1.movenext j = j + 1 loop rs1.close set rs1 = nothing 'dbConn.close set dbConn = nothing%> parent.inicia(); </script>
pagina pricipal que o usuário ve:
e;
document.FrmInclusao.cboSubCat.options.length = 0;
addItem(document.FrmInclusao.cboSubCat,"Aguarde...carregando","",false,document.FrmInclusao.cboSubCat.length)
myIframe.location = url;
document.FrmInclusao.cboSubCat.focus()
}
function inicia(){
local1 = new Array();
var maximo1, i, campo1;
local1 = myIframe.loc;
campo1 = document.FrmInclusao.cboSubCat;
maximo1 = local1.length;
document.FrmInclusao.cboSubCat.options.length = 0;
addItem(campo1,'TODAS','',false,campo1.length);
for (i=0;i<maximo1;i++){
addItem(campo1,local1*[1],local1**[0],false,campo1.length);*
}
}
function addItem(obj,strText,strValue,blSel,intPos){
var newOpt,i,ArTemp,selIndex;
* selIndex = (blSel)?intPos linenums:0'><script>function changeValue (obj) { var valor = obj.value; if (valor == "opção 1") document.getElementById("txt1").value = obj.value; else if (valor == "opção 2") document.getElementById("txt2").value = obj.value;}function carregar(){var url;url = 'remote.asp?cat='+document.FrmInclusao.cboCat[document.FrmInclusao.cboCat.selectedIndex].value;document.FrmInclusao.cboSubCat.options.length = 0;addItem(document.FrmInclusao.cboSubCat,"Aguarde...carregando","",false,document.FrmInclusao.cboSubCat.length)myIframe.location = url;document.FrmInclusao.cboSubCat.focus()}function inicia(){local1 = new Array();var maximo1, i, campo1;local1 = myIframe.loc;campo1 = document.FrmInclusao.cboSubCat;maximo1 = local1.length;document.FrmInclusao.cboSubCat.options.length = 0;addItem(campo1,'TODAS','',false,campo1.length);for (i=0;i<maximo1;i++){ addItem(campo1,local1**[1],local1**[0],false,campo1.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>*
<select name="cboSubCat" class="campostabela" id="cbosubcategoria" style="BORDER: #000000 1px solid; FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: verdana, arial, helvetica; BACKGROUND-COLOR: #FFFFFF"> </select>Carregando comentários...