<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Upload Multiple images with Captions</title>
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
(function (a) {
a.fn.relCopy = function (f) {
var b = jQuery.extend({
excludeSelector: ".exclude",
emptySelector: ".empty",
copyClass: "copy",
append: "",
clearInputs: true,
limit: 0
}, f);
b.limit = parseInt(b.limit);
this.each(function () {
a(this).click(function () {
var e = a(this).attr("rel"),
d = a(e).length;
if (b.limit != 0 && d >= b.limit) return false;
var c = a(e + ":first"),
g = a(c).parent();
c = a(c).clone(true).addClass(b.copyClass + d).append(b.append);
b.excludeSelector && a(c).find(b.excludeSelector).remove();
b.emptySelector && a(c).find(b.emptySelector).empty();
if (a(c).attr("id")) {
var h = a(c).attr("id") + (d + 1);
a(c).attr("id", h)
}
a(c).find("[id]").each(function () {
var i = a(this).attr("id") + (d + 1);
a(this).attr("id", i)
});
b.clearInputs && a(c).find(":input").each(function () {
switch (a(this).attr("type")) {
case "button":
break;
case "reset":
break;
case "submit":
break;
case "checkbox":
a(this).attr("checked", "");
break;
default:
a(this).val("")
}
});
a(g).find(e + ":last").after(c);
return false
})
});
return this
}
})(jQuery);
</script>
<script type="text/javascript">
$(function(){
var removeLink = ' <a class="remove" href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() }); return false">remove</a>';
$('a.add').relCopy({ append: removeLink});
});
</script>
</head>
<body>
<form method="post" action="clonesubmit.php">
<p class="clone"> <input type="text" name="hobby[]" class='input'/>
<input name="images[]" type="file"/>
</p>
<p><a href="#" class="add" rel=".clone">Add More</a></p>
<input type="submit" value=" Submit " />
</form>
</body>
</html>
No comments:
Post a Comment