Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
Select item value with radio buttons

function cittaBox() {
    var selezione = Document.getElementById("selector");
    var selezioneTxt = selezione.options[selezione.selectedIndex].text;
    Document.getElementById("txtBox").value=selezioneTxt;}
<SELECT NAME="citta" id="selector" onchange="cittaBox()">
                  <OPTION value="Roma">   Roma   </OPTION>
                  <OPTION value="Milano">   Milano   </OPTION>
                  <OPTION value="Torino">   Torino </OPTION>
                  <OPTION value="Napoli">   Napoli  </OPTION>
                  <OPTION value="Bari">   Bari    </OPTION>
                  <OPTION value="Taranto">   Taranto    </OPTION>
                  <OPTION value="Lecce">   Lecce    </OPTION>
               </SELECT>
               </P>
               <P align= "center" id="selezione0">
                  <INPUT type="text" name="citta" size="40" id="txtBox">
                </P>  

any idea on why it doesn't work?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

javascript is a case sensitive Use document instead of Document other than that nothing problem with your code

function cittaBox() {

    var selezione = document.getElementById("selector");
    var selezioneTxt = selezione.options[selezione.selectedIndex].text;
    document.getElementById("txtBox").value=selezioneTxt;
}

i hope you get answer..

about 4 years ago · Juan Pablo Isaza Relatório

0

replace Document.getElementById by document.getElementById

about 4 years ago · Juan Pablo Isaza Relatório

0

Your code looking good. But you have only one mistake. Change Documenttodocument`. Lowercase. Then it work.

function cittaBox() {
  console.log(1)
    var selezione = document.getElementById("selector");
    var selezioneTxt = selezione.options[selezione.selectedIndex].text;
    document.getElementById("txtBox").value=selezioneTxt;
}
<SELECT NAME="citta" id="selector" onchange="cittaBox()">
                  <OPTION value="Roma">   Roma   </OPTION>
                  <OPTION value="Milano">   Milano   </OPTION>
                  <OPTION value="Torino">   Torino </OPTION>
                  <OPTION value="Napoli">   Napoli  </OPTION>
                  <OPTION value="Bari">   Bari    </OPTION>
                  <OPTION value="Taranto">   Taranto    </OPTION>
                  <OPTION value="Lecce">   Lecce    </OPTION>
               </SELECT>
               </P>
               <P align= "center" id="selezione0">
                  <INPUT type="text" name="citta" size="40" id="txtBox">
                </P>  

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda