Jump to content


Photo

Menu Dinamico Com Redirecionamento Para Url


  • Faça o login para participar
1 reply to this topic

#1 princesasp

princesasp

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Não informado

Posted 15/03/2009, 15:01

Olá Pessoal,

Por favor eu tenho o seguinte código para criar um jump menu dinamico, mas gostaria que qdo o item da segunda janela fosse selecionado automaticamente fosse direcionado para uma url..o q devo mudar no código?

Grata

<html><head><title>Javascript Dynamic ListBox Demonstration</title></head><body bgcolor="#ffffff" OnLoad="setOption(document.ThisForm, 0)"><blockquote><form name="ThisForm"><!--  The listbox size should be same as the list which has the maximum size.   i.e. The number of "<option>" = the size of the maximum list.//--><select name="List1" OnChange="setOption(this.form, this.selectedIndex)"><option>Animals<option>Colours<option>Numbers<option>Places</select><p><select name="List2" OnChange="this.form.ValueIn2.value=this.options[this.selectedIndex].value"><option><option><option><option><option><option><option>_________________</select>  </form>&lt;script language="javascript"><!--function setOption(form, index) {  for (var i = 0; i < form.List2.length; i++) {    form.List2.options[i].text = "";    form.List2.options[i].value = "";  }  if (index == 0) {    form.List2.options[0].text = "Cat";    form.List2.options[0].value = "verdade"    form.List2.options[1].text = "Lion";    form.List2.options[1].value = "ani1";    form.List2.options[2].text = "Tiger";    form.List2.options[2].value = "ani2";    form.List2.options[3].text = "Dog";    form.List2.options[3].value = "ani3";    form.List2.options[4].text = "Cow";    form.List2.options[4].value = "ani4";    form.List2.options[5].text = "Snake";    form.List2.options[5].value = "ani5";    form.List2.options[6].text = "Monkey";    form.List2.options[6].value = "ani6";  }  else if (index == 1) {    form.List2.options[0].text = "Blue";    form.List2.options[0].value = "col0";    form.List2.options[1].text = "Red";    form.List2.options[1].value = "col1";    form.List2.options[2].text = "Yellow";    form.List2.options[2].value = "col2";    form.List2.options[3].text = "Green";    form.List2.options[3].value = "col3";    form.List2.options[4].text = "Orange";    form.List2.options[4].value = "col4";  }  else if (index == 2) {    form.List2.options[0].text = "One";    form.List2.options[0].value = "num0";    form.List2.options[1].text = "Two";    form.List2.options[1].value = "num1";    form.List2.options[2].text = "Three";    form.List2.options[2].value = "num2";    form.List2.options[3].text = "Four";    form.List2.options[3].value = "num3";    form.List2.options[4].text = "Five";    form.List2.options[4].value = "num4";  }  else if (index == 3) {    form.List2.options[0].text = "Airport";    form.List2.options[0].value = "pla0";    form.List2.options[1].text = "Railway Station";    form.List2.options[1].value = "pla1";    form.List2.options[2].text = "Museum";    form.List2.options[2].value = "pla2";    form.List2.options[3].text = "Stadium";    form.List2.options[3].value = "pla3";  }  form.List2.selectedIndex = 0;  form.ValueIn2.value = form.List2.options[form.List2.selectedIndex].value;}//--></script></blockquote><p><center></center></body></html>


#2 Alex Hiroshi

Alex Hiroshi

    Super Veterano

  • Ex-Admins
  • 4923 posts
  • Sexo:Masculino
  • Localidade:São Paulo - SP

Posted 16/03/2009, 10:03

É só trocar o onchange do segundo. Coloque algo como window.location.href = this.options[this.selectedIndex].value;
Fórum WMO - Equipe de Desenvolvimento / Banco de Dados - Ex-Administrador




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq