{% extends "base.html" %}
{% block title %} Editing Director: {{ director.Director_Name }} {% endblock %}
{% block script %}
	<script type="text/javascript" src="{{ url_for('static', filename='delete.js') }}"></script>
    <script type="text/javascript">

        window.onload = function() {

          //Get a reference to the link on the page
          // with an id of "mylink"
          var a = document.getElementById("cancel");
		  
          a.onclick = function() {
		  
			var title = document.getElementById("name")
			title.innerHTML = "{{ director.Director_Name }}"
			title.value = "{{ director.Director_Name }}"
			
			alert("The director with ID {{ director.Director_ID }} have been reset to their original values")
          }
        }
    </script>
{% endblock %}
{% block content %} 

	<div class="search-container">
		<form method="post" action="{{ url_for('directors.search') }}">
			<input id="text" type="text" placeholder="Search for Director.." name="keyword">
			<button class="w3-button w3-black" type="submit">Search</button>
		</form>
	</div>

<h1> Editing Director: {{ director.Director_Name }} </h1>

  {% set messages = get_flashed_messages() %}
  {% if messages %}
	<div class="w3-panel w3-pale-yellow w3-border">
		<h3> Please correct the following errors </h3>
			<ol class="w3-ul">
				{% for message in messages %}
					<li> {{ message }} </li>
				{% endfor %}
			</ol>
	</div>	
  {% endif %}

<span id="delete">
<form method="post" class="w3-container">
	<label for="id"><b>ID</b></label>
	<input type="number" value="{{ director.Director_ID }}" name="id" min="1" disabled required>
    <label for="name"><b>Name</b></label>
    <input type="text" id="name" value="{{ director.Director_Name }}" name="name" required>

    <p><button class="w3-button w3-black" onclick="return confirm('You are about to edit Director with ID {{ director.Director_ID }}')" 
	type="submit">Save</button> <a id="cancel" class="bttn w3-button w3-black">Reset</a></p>
</form>

<p><a class="alink" href="#" onclick="deleteEntity('delete','{{ url_for('directors.delete',Id=director.Director_ID) }}','{{ director.Director_Name }}')">
Delete Director</a> 
<a class="alink" href="{{ url_for('directors.index', page=1) }}">All Directors</a></p>
</span>
{% endblock %}
