Browse Source

El autor de la canción es por defecto el artista del álbum

politica
Celestino Rey 1 year ago
parent
commit
3efd6612ae
1 changed files with 15 additions and 1 deletions
  1. +15
    -1
      LyricsPy/templates/add_song.html

+ 15
- 1
LyricsPy/templates/add_song.html View File

@ -12,7 +12,7 @@
<label for="album_id">Álbum:</label>
<select id="album_id" name="album_id" required>
{% for album in albums %}
<option value="{{ album.id }}">{{ album.name }} by {{ album.artist }}</option>
<option value="{{ album.id }}" data-artist="{{ album.artist }}">{{ album.name }} by {{ album.artist }}</option>
{% endfor %}
</select>
@ -21,4 +21,18 @@
<button type="submit">Añadir canción</button>
</form>
<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>
{% endblock %}

Loading…
Cancel
Save