function addOption(obj) { var root=obj.parentNode.parentNode; root.parentNode.children[0].value=root.children.length+1; //var line=new htmlTag1(root,"div","formLine"); var line=document.createElement("div"); line.setAttribute("class","formLine"); insertAfter(obj.parentNode,line); var label=new htmlTag1(line,"label",""); var txt=document.createTextNode("Option:"); label.appendChild(txt); var inp=new htmlTag(line,"input","left"); inp.obj.setAttribute("type","text"); inp.obj.setAttribute("name","options[]"); inp=inp.append(); inp.focus(); inp=new htmlTag(line,"input","button"); inp.obj.setAttribute("type","button"); inp.obj.setAttribute("value","+"); inp.obj.onclick=function() { addOption(this); } inp=inp.append(); inp=new htmlTag(line,"input","button"); inp.obj.setAttribute("type","button"); inp.obj.setAttribute("value","-"); inp.obj.onclick=function() { removeOption(this); } inp=inp.append(); } function removeOption(obj) { var root=obj.parentNode.parentNode; root.parentNode.children[0].value=root.children.length-1; root.removeChild(obj.parentNode); } function newPoll (obj) { var root=obj.parentNode.parentNode; var item=document.createElement("div"); item.setAttribute("class","formItem"); var counter=new htmlTag(item,"input",""); counter.obj.setAttribute("type","hidden"); counter.obj.setAttribute("name","count[]"); counter.obj.value="2"; counter=counter.append(); root.insertBefore(item,obj.parentNode); var line=new htmlTag1(item,"div","formLine"); var label=new htmlTag1(line,"label",""); var text=document.createTextNode("Question:"); label.appendChild(text); var inp=new htmlTag(line,"input","left"); inp.obj.setAttribute("type","text"); inp.obj.setAttribute("name","questions[]"); inp=inp.append(); inp.focus(); var but=new htmlTag(line,"input","button"); but.obj.setAttribute("type","button"); but.obj.setAttribute("value","cancel"); but.obj.onclick=function() { removePollQuestion(this); } but=but.append(); var field=new htmlTag1(item,"div","pollsDynamicField"); line=new htmlTag1(field,"div","formLine"); var label=new htmlTag1(line,"label",""); var text=document.createTextNode("Option:"); label.appendChild(text); var inp=new htmlTag(line,"input"); inp.obj.setAttribute("type","text"); inp.obj.setAttribute("name","options[]"); inp=inp.append(); ///////////////////////// line=new htmlTag1(field,"div","formLine"); var label=new htmlTag1(line,"label",""); var text=document.createTextNode("Option:"); label.appendChild(text); var inp=new htmlTag(line,"input","left"); inp.obj.setAttribute("type","text"); inp.obj.setAttribute("name","options[]"); inp=inp.append(); but=new htmlTag(line,"input","button"); but.obj.setAttribute("type","button"); but.obj.setAttribute("value","+"); but.obj.onclick=function() { addOption(this); } but=but.append(); } function removePollQuestion(obj) { var yes=confirm ("Are you sure to remove this poll?"); if (!yes) return; obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode); } function pollSend(form) { var cu=new curtain(document.getElementById("pollsSendForm")); advAJAX.submit (form, { onSuccess: function (res) { cu.stop(); if (error=getAjaxResponse(res,"error")) { alert (error); } else location.href=base+"polls/showFolder/0.html"; } }); }