rendered paste body<!-- <pre><xar:set name="foo">print_r($current_page)</xar:set></pre> -->
<xar:if condition="isset($custom)">
<xar:set name="custom">current($custom)</xar:set>
<div id="maindiv" class="addProducts">
<ul>
<xar:foreach in="$custom" value="$naid">
<xar:set name="ainfo">xarmodapifunc('articles','user','get',array('aid' => $naid))</xar:set>
<li>New article, #$ainfo['title']#, created.</li>
</xar:foreach>
</ul>
<p style="text-align:center;"><a href="/multiples">Add some more.</a></p>
</div>
<xar:else />
<script type="text/javascript">
<!--
function addEvent()
{
var ni = document.getElementById('myDiv');
var numi = document.getElementById('theValue');
var num = (document.getElementById("theValue").value -1)+ 2;
numi.value = num;
var divIdName = "my"+num+"Div";
var newdiv = document.createElement('div');
newdiv.setAttribute("id",divIdName);
//newdiv.innerHTML = "Element Number "+num+" has been added! <a href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Remove the div ""+divIdName+""</a>";
newdiv.innerHTML = "<a class=\"removeProducts\" href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Remove this item</a><dl><dt>Title:</dt><dd><input name=\"title[]\" type=\"text\" /></dd><dt>Summary:</dt><dd><input name=\"summary[]\" type=\"textarea\" /></dd><dt>Body:</dt><dd><input name=\"body[]\" type=\"textarea\" /></dd><dt>Notes:</dt><dd><input name=\"author[]\" type=\"text\" /></dd></dl>";
//<a href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Remove this item</a>
ni.appendChild(newdiv);
}
function removeEvent(divNum)
{
var d = document.getElementById('myDiv');
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);
}
//-->
</script>
<xar:sec mask="SubmitArticles" catch="false">
<input type="hidden" value="0" id="theValue" />
<form name="the_form" id="the_form" method="post" action="#xarServerGetCurrentURL()#" style="clear:both;">
<div id="maindiv" class="addProducts">
<p>Multiple items example. This form uses JS to add additional sets of fields and submits
to a custom (simple) xarpages function that loops thru each set with the articles-admin-create
api.<strong>Title is required.</strong></p>
<dl>
<dt>Title:</dt>
<dd><input name="title[]" type="text" /></dd>
<dt>Summary:</dt>
<dd><input name="summary[]" type="textarea" /></dd>
<dt>Body:</dt>
<dd><input name="body[]" type="textarea" rows="3" /></dd>
<dt>Notes:</dt>
<dd><input name="author[]" type="text" /></dd>
</dl>
<div id="myDiv"> </div>
<p style="text-align:right;"><a href="javascript:;" onclick="addEvent();" title="Click here to add multiple items at once.">Add another article</a> or
<input type="submit" value="Submit Article(s)" />
</p>
</div>
</form>
<xar:else />
Sorry.
</xar:sec>
</xar:if>