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

124
Views
Show what's choosen in JavaScript's combobox

Ok so im new to JavaScript and programing in general so i got this kind of assignment that isnt hard but i still cant manage to figure it out...I need to make combo box in form,and create a div outside that form.Then i need JS function that will show what have i choosed from combo box into that div...

<script>
    function omiljeniFilm(){
        var lista=document.getElementById("lista");
        var ispis=lista.options[lista.selectedIndex].text;
        document.getElementById("omiljeni").value=ispis;
    }
</script>
<body>
    <form>
        Izaberi omiljeni film:
    <select id="lista" onchange="omiljeniFilm();">
        <option>Gospodar prstenova</option>
        <option>Hari Poter</option>
        <option>Pobesneli Maks</option>
        <option>Titanik</option>
    </select>    
    </form>
    <div id="omiljeni">
    </div>
</body>

I used the same function that i write before for very similar assignment that adds choosen words to forms input element but it doesnt work with this div outside the form...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need two changes

  • To get the select value use the value property
  • To set the div text use the innerText property

the function would be:

function omiljeniFilm(){
    var lista=document.getElementById("lista");
    document.getElementById("omiljeni").innerText=lista.value;
}
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!