Crear un input a partir de un select
Publicado por Javier (22 intervenciones) el 10/04/2020 08:02:20
Buenas amigos, tengo un problema al intentar crear un input si se selecciona una opción en un select por ejemplo si yo selecciono Arial quiero intentar que aparezca un input extra solo en esa seleccion, sera posible? y muchas gracias por toda su ayuda

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="css/estilos.css">
<meta charset="utf8">
<script>
function mostrar(objeto)
{
if(objeto.value==0)
{
document.getElementById("idSeleccionado").value="text";
document.getElementById("textoSeleccionado").value="";
}else{
document.getElementById("idSeleccionado").value=objeto.value;
document.getElementById("textoSeleccionado").value=objeto[objeto.value].innerHTML;
}
}
</script>
</head>
<body>
<select onchange="mostrar(this)">
<option value="a" selected="selected">Selecciona una opción</option>
<option value="font-family: arial;" class="betosierra">Arial</option>
<option value="font-family: cursive;" class="betoquintanilla">Cursive</option>
<option value="d">opcion 3</option>
<option value="f">opcion 4</option>
<option value="g">opcion 5</option>
</select>
<p>
Codigo CSS <input type="text" id="idSeleccionado">
</p>
<input type="text" name="holiwis" class="holiwis">
</body>
</html>

Valora esta pregunta


0