diff --git a/django/contrib/admin/templates/admin/prepopulated_fields_js.html b/django/contrib/admin/templates/admin/prepopulated_fields_js.html
index e1cdb96..3b56a45 100644
a
|
b
|
|
2 | 2 | {% for field in prepopulated_fields %} |
3 | 3 | document.getElementById("{{ field.field.auto_id }}").onchange = function() { this._changed = true; }; |
4 | 4 | {% for dependency in field.dependencies %} |
5 | | document.getElementById("{{ dependency.auto_id }}").onkeyup = function() { |
| 5 | function field_{{ field.field.auto_id }}() { |
6 | 6 | var e = document.getElementById("{{ field.field.auto_id }}"); |
7 | | if (!e._changed) { e.value = URLify({% for innerdep in field.dependencies %}document.getElementById("{{ innerdep.auto_id }}").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:"50" }}); } |
| 7 | if (!e._changed) { |
| 8 | {% for innerdep in field.dependencies %} |
| 9 | var val_elm = document.getElementById("{{ innerdep.auto_id }}"); |
| 10 | if (val_elm.tagName == "SELECT") { |
| 11 | e.value = URLify(val_elm.options[val_elm.selectedIndex].text{% if not forloop.last %} + ' ' + {% endif %}, {{ field.field.field.max_length|default_if_none:"50" }}); |
| 12 | }else{ |
| 13 | e.value = URLify(val_elm.value{% if not forloop.last %} + ' ' + {% endif %}, {{ field.field.field.max_length|default_if_none:"50" }}); |
| 14 | } |
| 15 | {% endfor %} |
| 16 | } |
8 | 17 | } |
| 18 | addEvent(document.getElementById("{{ dependency.auto_id }}"), 'keyup', field_{{ field.field.auto_id }}); |
| 19 | addEvent(document.getElementById("{{ dependency.auto_id }}"), 'change', field_{{ field.field.auto_id }}); |
| 20 | |
9 | 21 | {% endfor %} |
10 | 22 | {% endfor %} |
11 | 23 | </script> |