function saveForm(divFrm)
{
this.frm = divFrm;
if(!this.frm) alert("Formular nicht gefunden: "+frmID);
}
saveForm.prototype.getAll = function()
{
this.text="";
this.chk="";
this.radio=""
this.select="";
this.textarea="";
this.iframe="";
this.getData("input");
this.getData("select");
this.getData("textarea");
this.getData("iframe");
var dat = this.text;
//this.debug(this.text);
dat += this.chk;
dat += this.radio;
dat += this.select;
dat += this.textarea;
dat += this.iframe;
dat += this.getCheckreihen();
dat = dat.substr(1);
return dat;
}
saveForm.prototype.debug = function(dat)
{
var t = dat.split("&");
var nu = "
"
for (var i=0,len=t.length; i < len; i++)
{
var w = t[i].split("=");
nu += "| " + w[0] + " | " + w[1] + " |
"
}
nu += "
"
dodebug(nu);
}
saveForm.prototype.getData = function(fTyp)
{
var inps = this.frm.getElementsByTagName(fTyp);
for (var i=0,len=inps.length; i < len; i++)
{
var inp = inps[i];
var fname = escape(inp.name);
var w = getWert(inp.value);
w = w.replace(String.fromCharCode(367),"ů");
w = w.replace(String.fromCharCode(328),"ň");
w = w.replace(String.fromCharCode(345),"ř");
w = w.replace(String.fromCharCode(269),"č");
var valu = escape(w);
switch(fTyp)
{
case "input":
if(inp.type!=="button")
{
switch(inp.type)
{
case "text":
this.text += "&"+fname+"="+valu;
break;
case "hidden":
this.text += "&"+fname+"="+valu;
break;
case "checkbox":
if(inp.getAttribute("typ")!=="checkreihe")
{
var wert="";
//if(inp.checked) wert = inp.value;
//this.chk += "&"+fname+"="+wert;
if(inp.checked)
{
wert = inp.value;
this.chk += "&"+fname+"="+wert;
}
}
break;
case "radio":
if(inp.checked)
{
wert = inp.value;
this.radio += "&"+fname+"="+wert;
}
break;
}
}
break;
case "select":
this.select += "&"+fname+"="+valu;
break;
case "textarea":
if(!inp.getAttribute("omit"))
{
valu = valu.replace("%0D%0A","%0A");
this.textarea += "&"+fname+"="+valu;
}
break;
case "iframe":
var oDoc = (inp.contentWindow || inp.contentDocument);
if (oDoc.document) oDoc = oDoc.document;
this.iframe += "&"+fname+"="+escape(oDoc.body.innerHTML);
}
}
}
saveForm.prototype.getCheckreihen = function()
{
var felder = "";
var inps = this.frm.getElementsByTagName("input");
for (var i=0,len=inps.length; i < len; i++)
{
var inp = inps[i];
if (inp.type == "checkbox")
{
if(inp.getAttribute("typ")=="checkreihe")
{
if(felder.indexOf(inp.name)==-1)
{
felder += inp.name + ",";
}
}
}
}
var reihen = "";
var t = felder.split(",");
for (var i=0,len=t.length-1; i < len; i++)
{
var feld = t[i];
reihen += this.getReihe(feld);
}
return reihen;
}
saveForm.prototype.getReihe = function(feld)
{
var reihe = "";
var chk = this.frm.getElementsByTagName("input");
{
for (var i=0,len=chk.length; i < len; i++)
{
var chkBox = chk[i];
if (chkBox.name == feld && chkBox.checked)
{
reihe += chkBox.value+",";
}
}
}
var max = 0;
reihe = reihe.slice(0,-1);
var t = reihe.split(",");
for (var i=0,len=t.length; i < len; i++)
{
var t2 = t[i].split(":");
var posi = parseInt(t2[0]);
if(posi>max) max = posi;
}
var nu = new Array(max+1).join('_');
for (var i=0,len=t.length; i < len; i++)
{
var t2 = t[i].split(":");
var posi = parseInt(t2[0]);
var wert = t2[1];
nu = mid2(nu,posi,wert);
}
reihe = "&" + feld + "=" + nu;
return reihe;
}
function mid2(tx,posi,wert)
{
var arr = ('' + tx).split('');
arr[posi-1] = wert;
var nu = arr.join('');
return nu;
}
saveForm.prototype.clear = function()
{
this.clearEl("input");
this.clearEl("textarea");
}
saveForm.prototype.clearEl = function(typ)
{
var inps = this.frm.getElementsByTagName(typ);
for (var i=0,len=inps.length; i < len; i++)
{
if(inps[i].type!=="button") inps[i].value="";
if(inps[i].type=="checkbox") inps[i].checked=false;
}
}