You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

57 lines
2.1 KiB

{% extends 'base.html' %}
{% block content %}
<div class="column is-4 is-offset-4">
<h3>Añadir nueva canción</h3>
<div class="box">
<form method="POST" action="/add_song">
<div class="text mb-3">
<label for="pista">Nº de pista:</label>
<input class="form-control" type="number" id="pista" name="pista" required>
</div>
<div class="text mb-3">
<label for="title">Título:</label>
<input class="form-control" type="text" id="title" name="title" required>
</div>
<div class="text mb-3">
<label for="author">Autor:</label>
<input class="form-control" type="text" id="author" name="author" required>
</div>
<div class="text mb-3">
<label for="album_id">Álbum:</label>
<select class="form-control" id="album_id" name="album_id" required>
{% for album in albums %}
<option value="{{ album.id }}" data-artist="{{ album.artist }}">{{ album.name }} by {{ album.artist }}</option>
{% endfor %}
</select>
</div>
<div class="text mb-3">
<label for="lyrics">Letra:</label>
<textarea class="form-control" id="lyrics" name="lyrics" required></textarea>
</div>
<div class="text mb-3">
<button type="submit" class="btn app-btn-primary w-100 theme-btn mx-auto">Añadir canción</button>
</div>
</form>
</div>
<script>
function updateAuthor() {
var albumSelect = document.getElementById("album_id");
var selectedAlbum = albumSelect.options[albumSelect.selectedIndex];
var artist = selectedAlbum.getAttribute("data-artist");
document.getElementById("author").value = artist;
}
// Initialize the author field with the artist of the first album
document.addEventListener('DOMContentLoaded', function() {
updateAuthor();
});
</script>
</div>
{% endblock %}