bberry91
27 Apr 2011, 08:25 AM
i would like a form that has one repetative field. if the user would like to enter more of the fields (ex. files) , they click on a button to show more fields.
MarPlo
27 Apr 2011, 12:56 PM
Hy,
Try test and use this example.
The user can add text-fields, but you can replace it with type="file"
<script type="text/javascript">
<!--
// - www.coursesweb.net/javascript/
// creates an input element and adds it before the Submit button
function add_input() {
var new_input = document.createElement("input");
new_input.setAttribute("type", "text");
new_input.setAttribute("name", "nume[]");
new_input.style.display = 'block'; // Seteaza display:block; pt. a afisa casutele unele sub altele
// sets the objects for reference (reper) and parent
var reper = document.getElementById('submit');
var parinte = reper.parentNode;
// Adds the new element
parinte.insertBefore(new_input, reper);
}
//-->
</script>
<form action="">
<input type="text" name="nume[]" />
<input type="submit" value="Submit" id="submit" /><br /><br />
<input type="button" value="Add field" onclick="add_input()" />
</form>
Powered by vBulletin® Version 4.2.0 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.