Studyon Minte9.com
jQuery




Form add element



<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

<a href="#" onClick="addFormField(); return false;">Add</a>
<form action="#" method="get" id="form1">
	<input type="hidden" id="fieldOrder" value="1">
<div id="divTxt"></div>
</form>

<script>
function addFormField() {
	var id = document.getElementById("fieldOrder").value;
	$("#divTxt").append("<p id='row" + id + "'><label for='txt" + id + "'>Field " + id + " 
<input type='file' size='20' name='images[]' id='images" + id + "'> 
<a href='#' onClick='removeFormField("#row" + id + ""); return false;'>Remove</a><p>");

	id = (id-1) + 2;
	document.getElementById("fieldOrder").value = id;
}

function removeFormField(id) {
	$(id).remove();
}
</script>