Commit b2fe0312 authored by Boris Kocherov's avatar Boris Kocherov

fix render_selection()

parent 6da36ae6
......@@ -112,7 +112,8 @@
function render_selection(schema, json_document) {
var input = document.createElement("select"),
option,
option_index;
i,
enum_arr = schema['enum'];
input.size = 1;
if (schema.default) {
if (json_document === undefined) {
......@@ -122,17 +123,17 @@
option = document.createElement("option");
option.value = "";
if (json_document === undefined) {
option.selected = "selected";
option.selected = true;
}
input.appendChild(option);
}
for (option_index in schema['enum']) {
if (schema['enum'].hasOwnProperty(option_index)) {
for (i = 0; i < enum_arr.length; i += 1) {
if (enum_arr.hasOwnProperty(i)) {
option = document.createElement("option");
option.value = schema['enum'][option_index];
option.textContent = schema['enum'][option_index];
if (schema['enum'][option_index] === json_document) {
option.selected = "selected";
option.value = enum_arr[i];
option.textContent = enum_arr[i];
if (enum_arr[i] === json_document) {
option.selected = true;
}
input.appendChild(option);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment