Skip to content
The Chat Archive
gpt-3.5-turbo-0301· OpenAI WildChat-4.8M (AI2)

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport"…

  1. User
      </nav>
    </header>
    <main>
      <!-- добавляет форму с поиском музыкантом -->
      <form action="/search" method="get">
    	<label for="query">Search by name or genre:</label> <input id="query" name="query" type="text" value="<%= query %>"><br>
    	<br>
    	<label for="role">Search by role:</label> <select id="role" name="role">
    		<option value="">
    			All
    		</option>
    		<option value="Band">
    			Band
    		</option>
    		<option value="Artist">
    			Artist
    		</option>
    	</select>
    	
    

    Search by location:

    	<br>
    	<!-- Add new input field for location -->
    
    
    	<br>
    	
    	<br>
    	<button type="submit">Search</button>
    </form><%if (musicians.length > 0) { %>
    <h2>Results:</h2>
    <ul>
    	<%musicians.forEach(musician => { %>
    	<li>
    		<a href="<%= musician.profileLink %>"><%= musician.name %> <%if (musician.thumbnail) { %> <img src="/img/<%= musician.thumbnail %>" alt="<%= musician.name %>"> <%} %></a> - <%= musician.genre %> - <%= musician.location %> <%if (musician.soundcloud) { %> <a href="%3C%=%20musician.soundcloud%20%%3E">SoundCloud</a> <%} %>
    	</li><%}); %>
    </ul><%} else if (query || role) { %>
    <p>No musicians found.</p><%} %>
    <!--  -->
    

    const queryInput = document.querySelector("#query"); const roleInput = document.querySelector("#role"); const cityInput = document.querySelector("#city");

    queryInput.value = "<%= query %>"; roleInput.value = "<%= role %>"; cityInput.value = cityInput.getAttribute('data-value');

    const query = queryInput.value; const role = roleInput.value; const city = cityInput.value;

    ReferenceError: C:\Users\Ilya\Downloads\my-musician-network\views\index.ejs:33 31|

    32| 	  <form action="/search" method="get">
    

    33| Search by name or genre:

    34| 		<br>
    
    35| 		<label for="role">Search by role:</label> <select id="role" name="role">
    
    36| 			<option value="">
    

    query is not defined

  2. Assistant

    This error message is indicating that the variable query is not defined in the current scope. It seems that the issue is in the EJS template file index.ejs at line 33 where the value of the input field for search by name or genre is being set using <%= query %>.

    Make sure that the query variable is defined before the EJS file is rendered, and that it is passed as a parameter to the res.render function when rendering the page.