X-Git-Url: http://cgit.babelmonkeys.de/?p=adhocweb.git;a=blobdiff_plain;f=js%2Fmain.js;h=955ceb9f5d9a0795529b5f9a9d577e134789b73c;hp=1b2aebb9edfd9a28ae29104d107ba420c84371b2;hb=cbd50cbce1874f5b7372df7b9754a938593134b6;hpb=1bd007700979548e6695de7f2997223f3fd931d9
diff --git a/js/main.js b/js/main.js
index 1b2aebb..955ceb9 100644
--- a/js/main.js
+++ b/js/main.js
@@ -97,15 +97,15 @@ function addForm(elem, x) {
break;
case "list-multi":
item = $("");
- $(this).find("option").each(function(){
- $("").val($(this).find("value").text()).text($(this).attr("label")).appendTo(item);
- });
+ $(this).find("option").each(function() {
+ $("").val($(this).find("value").text()).text($(this).attr("label")).appendTo(item);
+ });
break;
case "list-single":
item = $("");
- $(this).find("option").each(function(){
- $("").val($(this).find("value").text()).text($(this).attr("label")).appendTo(item);
- });
+ $(this).find("option").each(function() {
+ $("").val($(this).find("value").text()).text($(this).attr("label")).appendTo(item);
+ });
break;
case "text-private":
item = $("");
@@ -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++)