Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
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 answers
Answer question

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 Report

0

replace Document.getElementById by document.getElementById

about 4 years ago · Juan Pablo Isaza Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!