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

183
Vistas
How do I trigger JS functions in HTML within a form element using select/option tags?

I am working on a network scripting generator that utilizes HTML and JS. The user inputs values, and the output auto generates/updates with every change to the input values using either the onChange, onKeyUp, or OnClick event triggers to trigger the current form values to run through the JS function.

Any input elements, including text and radio types, work just fine, but to save real estate I'd like to convert a number of the radio lists into dropdown menus using either select or datalist plus option elements. However, doing this conversion seems to break things and the function no longer runs or the output doesn't generate.

I'm guessing there is some fundamental form concept I am missing here. The code snippet here shows a simplified summary of what I'm attempting to do. I've tried variations of including event triggers onSelect, onChange, and onClick in the option tag as well as the select tag, but no joy. Same thing using datalists. Anyone know what I'm doing wrong?

Doesn't Work:

<head>
<script type="text/javascript" src="functions.js"></script>
</head>

<body>
<form name="example">
<div>
    <table>
        <tr><td>Speed</td></tr>
        <tr>
            <td>
                <select name="speed" onChange="exampleName()">
                    <option value="5M" >5M</option>
                    <option value="10M">10M</option>
                    <option value="15M">15M</option>
                </select>
            </td>
        </tr>
    </table>
</div>
</form>
</body>

Works:

<head>
<script type="text/javascript" src="functions.js"></script>
</head>

<body>
<form name="example">
<div>
    <table>
        <tr><td>Speed</td></tr>
        <tr><td><input type="radio" name="speed" value="5M" onClick="exampleName()" checked="" >5M</input></td></tr>
        <tr><td><input type="radio" name="speed" value="10M" onClick="exampleName()">10M</input></td></tr>
        <tr><td><input type="radio" name="speed" value="15M" onClick="exampleName()">15M</input></td></tr>
    </table>
</div>
</form>
</body>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I figured out my issue after going through all the code. It wasn't a naming issue, and it wasn't even really an HTML issue. It was actually the JS which was setup up to parse through radio inputs to find checked fields. This didn't work with select/option because they get "selected" vs "checked" states.

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