<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<script>
// una vez se haya cargado la pagina
window.onload=function(){
// creamos el selector
var selector = document.createElement('select');
selector.id = 'Selector';
selector.name = 'Selector';
// Lo añadimos al id miSelector de la pagina html
document.getElementById("miSelector").appendChild(selector);
// definimos las opciones del selector
var option = document.createElement('option');
option.value = '0';
option.appendChild(document.createTextNode('Selecciona...'));
selector.appendChild(option);
option = document.createElement('option');
option.value = '1';
option.appendChild(document.createTextNode('Coche'));
selector.appendChild(option);
option = document.createElement('option');
option.value = '2';
option.appendChild(document.createTextNode('Moto'));
selector.appendChild(option);
}
</script>
</head>
<body>
Selecciona un vehículo :<span id="miSelector"></span>
</body>
</html>
Comentarios sobre la versión: Versión 1 (0)
No hay comentarios