One other question I have is actually about the expanding form and may be more of a javascript issue than php, so sorry if this is the wrong place for this....
When you complete the fields for the first article and then click "add another..." the next set of input fields are pre-filled with the same info entered into article1.
Is there a way to clear/reset the new form fields as they are cloned?
Here is the js I'm using:
<script type="text/javascript">
function trimNums(stringToTrim)
{
return stringToTrim.replace(/\d+$/,"");
}
function dupForm(divId, divClass, btnAdd, btnRm)
{
//alert(divId+' '+divClass);
var num = $(divClass).length;
var newNum = new Number(num + 1);
var i;
var newElem = $('#' + divId + num).clone().attr('id', divId + newNum);
for (i=0; i < newElem.children().length; i++)
{
var attrId = trimNums(newElem.children(':eq('+i+')').attr('id'));
var attrName = trimNums(newElem.children(':eq('+i+')').attr('name'));
newElem.children(':eq('+i+')').attr('id', attrId + newNum).attr('name', attrName);
}
$('#' + divId + num).after(newElem);
$('#' + btnRm).attr('disabled','');
if (newNum == 15)
$('#' + btnAdd).attr('disabled','disabled');
}
function rmForm(divId, divClass, btnAdd, btnRm)
{
var num = $(divClass).length;
$('#' + divId + num).remove();
$('#' + btnAdd).attr('disabled','');
if (num-1 == 1)
$('#' + btnRm).attr('disabled','disabled');
}
</script>