Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda