From: Florian Zeitz Date: Sun, 19 Dec 2010 01:57:06 +0000 (+0100) Subject: Add support for list-multi X-Git-Url: https://git.babelmonkeys.de/?a=commitdiff_plain;h=c61edf2757c92c0460b9e0581771f7a9b06ed1ba;p=adhocweb.git Add support for list-multi --- diff --git a/js/main.js b/js/main.js index b634c9a..955ceb9 100644 --- a/js/main.js +++ b/js/main.js @@ -123,9 +123,10 @@ function addForm(elem, x) { }); item.val(value); } else if (type == "list-multi") { - value = new Array(); - $(this).find("value").each(function() { - value[value.length] = $(this).text(); + $(this).children("value").each(function() { + item.children('option[value="' + $(this).text() + '"]').each(function() { + $(this).attr("selected", "selected"); + }); }); } else { item.val($(this).find("value").text()); @@ -150,8 +151,8 @@ function serializeToDataform(form, st) { st.c("field", {"var": $(this).attr("name")}); if (this.nodeName.toLowerCase() == "select" && this.multiple) { for (var i = 0; i < this.options.length; i++) - if (options[i].selected) - st.c("value").t(options[i]).up(); + if (this.options[i].selected) + st.c("value").t(this.options[i].text).up(); } else if (this.nodeName.toLowerCase() == "textarea") { var sp_value = this.value.split(/\r?\n|\r/g); for(var i = 0; i < sp_value.length; i++)