| Nome | Título Tópicos |
| Mauricio Junior |
Dúvida iniciada: 10/6/2006 10:24:58 AM
Passa de combo grande para outra
Dúvida: Passa de uma combo grande para outra.
//Efetua a transferência de options entre 2 selects //Ex: // botão >> = onClick="s_SelectMultiplo(document.form1.cboOrigem, document.form1.cboDestino, true);" // botão << = onClick="s_SelectMultiplo(document.form1.cboDestino, document.form1.cboOrigem, true);" //Parâmetros: objeto de origem, objeto de destino, ordena listagem
function s_SelectMultiplo(oOrigem, oDestino, bOrdena){ var sListagemDestino = ""; var oOption = ""; var sValoresDoOrigem = ""; var sValoresDoDestino = ""; var sSubValorOrigem = ""; var sSubValorDestino = ""; var sValor = ""; var sTexto = ""; var bTemSelecionado = false; for (var i = 0; i < oDestino.options.length; i++){ sListagemDestino += "§"+ oDestino.options[i].text+"22"; } for (var i = (oOrigem.options.length - 1); i >= 0 ; i--){ if (oOrigem.options[i].selected == true && sListagemDestino.indexOf(oOrigem.options[i].text + "22") == -1){ bTemSelecionado = true; sValoresDoOrigem += oOrigem.options[i].text +"="+ oOrigem.options[i].value +"§§" oOrigem.remove(i); } }
if (bTemSelecionado == false){return;} sValoresDoOrigem = sValoresDoOrigem.substr(0, sValoresDoOrigem.length - 2); sValoresDoOrigem = sValoresDoOrigem.split("§§"); for (var i = 0; i < sValoresDoOrigem.length; i++){ sSubValorOrigem = sValoresDoOrigem[i]; sSubValorOrigem = sSubValorOrigem.split("="); sTexto = sSubValorOrigem[0]; sValor = sSubValorOrigem[1]; oOption = new Option(sTexto, sValor); oDestino.options[oDestino.options.length] = oOption; } if (bOrdena == true){ for (var i = (oDestino.options.length - 1); i >= 0 ; i--){ sValoresDoDestino += oDestino.options[i].text +"="+ oDestino.options[i].value +"§§" oDestino.remove(i); } sValoresDoDestino = sValoresDoDestino.substr(0, sValoresDoDestino.length - 2); sValoresDoDestino = sValoresDoDestino.split("§§"); sValoresDoDestino.sort(); for (var i = 0; i < sValoresDoDestino.length; i++){ sSubValorDestino = sValoresDoDestino[i]; sSubValorDestino = sSubValorDestino.split("="); sTexto = sSubValorDestino[0]; sValor = sSubValorDestino[1]; oOption = new Option(sTexto, sValor); oDestino.options[oDestino.options.length] = oOption; } } if (oOrigem.options[0]){ oOrigem.options[0].selected = true; } return; }
|