title: onchange can't find function
body: <p>I'm trying to make an <code>input</code> change value depending on another <code>input</code>s value.</p>
  
  <p>What I've come up with so far is this. But when running the <code>onchange</code> commmand I get an error that <code>updateCity</code> doesn't exist. Even thou it's there. Am I doing something wrong, is pretty new to coding with <code>javascript</code>. </p>
  
  <pre><code>&lt;div class="form-inline"&gt;
      &lt;div class="form-group"&gt;
          &lt;label class="sr-only" for="zip"&gt;Indtast postnummer&lt;/label&gt;
          &lt;input class="form-control" type="text" name="register_zip" id="zip" placeholder="Indtast postnummer" value="@city.zip" onchange="updateCity(this.value)" /&gt;
      &lt;/div&gt; &lt;!-- class="form-group" --&gt;
  
      &lt;div class="form-group"&gt;
          &lt;label class="sr-only" for="city"&gt;Indtast by&lt;/label&gt;
          &lt;input class="form-control" type="text" name="register_city" id="city" placeholder="Indtast by" value="@city.name" /&gt;
      &lt;/div&gt; &lt;!-- class="form-group" --&gt;
  &lt;/div&gt;
  &lt;script&gt;
      function updateCity(city_zip) {
              var city = findCity(city_zip);
  
              if(city != null){
                  document.getElementById("register_city").value = city_name;
              }
          };
  
          function findCity(zip){
              var cities = [];
              @{
                  foreach (var c in cities)
                  {
                      &lt;text&gt;
                          cities.push({zip: @c.zip, name: @c.name});
                      &lt;/text&gt;
                  }
              }
  
              for(var i=0;i&lt;cities.length;i++){
                  if(cities[i].zip == zip){
                      return cities[i]
                  }
              }
          };
  &lt;/script&gt;
  </code></pre>