<p><strong>Instrument:</strong> должен быть скрыт в профиле, если выбрана роль band.…
- User
profile.ejs:
<div id="edit-profile-modal" class="modal"> <div class="modal-content"> <span class="close">×</span> <h2>Edit Profile</h2> <form action="/profile/<%= musician.id %>/edit" method="POST" enctype="multipart/form-data"> <div> <label for="name">Name:</label> <input type="text" id="name" name="name" value="<%= musician.name %>"> </div> <div> <label for="name">Role:</label> <input type="role" id="role" name="role" value="<%= musician.role %>"> </div> <div> <label for="genre">Genre:</label> <input type="text" id="genre" name="genre" value="<%= musician.genre %>"> </div> <div> <label for="instrument">Instrument:</label> <input type="text" id="instrument" name="instrument" value="<%= musician.instrument %>"> </div> <div> <label for="location">Location:</label> <input type="text" id="location" name="location" value="<%= musician.location %>"> </div> <div> <label for="bio">Bio:</label> <textarea id="bio" name="bio"><%= musician.bio %></textarea> </div> <div> <label for="soundcloud">Song 1:</label> <input type="text" id="soundcloud" name="soundcloud" value="<%= musician.soundcloud %>"> </div> <div> <label for="soundcloud">Song 2:</label> <input type="text" id="soundcloud1" name="soundcloud1" value="<%= musician.soundcloud1 %>"> </div> <div> <label for="thumbnail">Thumbnail:</label> <input type="file" id="thumbnail" name="thumbnail"> </div> <button type="submit">Save</button> </form> </div> </div> <!-- <div> <input type="text" name="soundcloud[]" placeholder="Soundcloud track URL"> <button type="button" class="add-music-button">Add Music</button> </div> </div> </div> <div> <label for="thumbnail">Thumbnail:</label> <input type="file" id="thumbnail" name="thumbnail"> </div> <button type="submit">Save</button> </form> </div> </div> --> <% } %> <script>const modal = document.getElementById("edit-profile-modal"); const btn = document.getElementsByTagName("a")[0]; const span = document.getElementsByClassName("close")[0];
btn.onclick = function() { modal.style.display = "block"; } span.onclick = function() { modal.style.display = "none"; } window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } //скрыть плеер, если ссылка не внесена const song1Input = document.getElementById("soundcloud");const song2Input = document.getElementById("soundcloud1"); const player1 = document.getElementsByTagName('iframe')[0]; const player2 = document.getElementsByTagName('iframe')[1]; let songs = { song: "", song1: "" }
function hidePlayer(player) { player.src = ""; player.style.display = "none"; }
- Assistant
Нужно добавить класс "instrument-field" к элементу в разделе Instrument, чтобы его можно было скрыть при выборе роли Band. Затем добавить свойство "display: none" для этого элемента в файле main.css. Также нужно добавить условие в файл register.ejs для скрытия поля Instrument при выборе роли Band при регистрации.
profile.ejs:
...
...
main.css:
...
.instrument-field { display: none; }
...
register.ejs:
...
Role
Instrument
...