-1
저는 javascript를 처음 사용하고 jquery에 대한 경험이 거의 없습니다. 다음은 여러 후보자에 대해 양식을 반복 할 수 있지만 대부분 잘 작동하지만 관련 행에 다음과 같이 선택 목록을 첨부하면 도움이 필요하며 제거 버튼은 현재 각 선택 목록을 제거하지 않습니다.선택 목록이있는 동적 JavaScript 양식
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script>
(function($) {
$newcountForms = 1;
$.fn.newaddForms = function() {
var newform = "<table>" + "<tr>" + "<td>First Name: <input type='text' name='FirstName[" + $newcountForms + "]'></td>" + "<td>Last Name: <input type='text' name='LastName[" + $newcountForms + "]'></td>" + "<td>Sex:</td><td> <input type='radio' name='Sex[" + $newcountForms + "]' value='Male'>Male<br>" + "<input type='radio' name='Sex[" + $newcountForms + "]' value='Female'>Female</td>" + "<td><button>remove</button></td>" + "</tr>" + "</table>";
newform1 = $("<div>" + newform + "</div>");
$("button", $(newform1)).click(function() {
$(this).parent().parent().remove();
});
$(this).append(newform1);
var s = $('<select/>');
var o = [1, 2, 3];
for (var i in o) {
s.append($('<option/>').html(o[i]));
}
$("button", $(s)).click(function() {
$(this).parent().parent().remove();
});
$(this).append(s);
$newcountForms++;
};
})(jQuery);
$(function() {
$("#newbutton").bind("click", function() {
$("#newcands").newaddForms();
});
});
</script>
</head>
<body>
<!-- Button For New Candidates -->
<button id="newbutton">
New Candidate
</button>
<form>
<p>
<div id="newcands"></div>
</p>
</form>
</body>
</html>
데모처럼 newForm1에 선택 추가 http://jsfiddle.net/arunpjohny/2YsQR/1/ –
시도 http://jsfiddle.net/arunpjohny/2YsQR/2 /이게 니가 찾고있는거야 –