フォーム
<form id="form1" name="form1" method="post" action="">
name_field
<input type="text" name="field_1" id="field_1" />
<a href="#" id="dup" name="dup" >Use same</a>
<input type="text" name="field_2" id="field_2" />
<input type="text" name="field_3" id="field_3" />
...
<input type="text" name="field_x" id="field_x" />
</form>
field_1 を field_1 から field_x まで複製する ajax スクリプトを探しています。これは、すべてのプレーヤーにチームの名前を入力する方法です。
$(".dup").click(function() {
var myinput = $( ".field_1" ).val();
$("input[class^='field_']").html(myinput);
});
$(".dup").live("click", function(e) {
var count = $(".form1 fieldset").length + 1;
$(this).parent().clone().insertBefore("#sbmt").find("input[type=text]").attr({
"id": "input" + count,
"name": "input" + count
}).val("");
});
// アップデート:
may フィールドはこのタイプであることが判明しました: そして、変更は 3 の倍数で行われます..
<input id="field_1" type="text" name="Item[fields][1]" ><a href="#" id="dup1">Use Info</a>
<input id="field_2" type="text" name="Item[fields][2]" ><a href="#" id="dup2">Use Team</a>
<input id="field_3" type="text" name="Item[fields][3]" ><a href="#" id="dup3">Use Year</a>
<input id="field_4" type="text" name="Item[fields][4]" >
<input id="field_5" type="text" name="Item[fields][5]" >
<input id="field_6" type="text" name="Item[fields][6]" >
<input id="field_7" type="text" name="Item[fields][7]" >
<input id="field_8" type="text" name="Item[fields][8]" >
<input id="field_9" type="text" name="Item[fields][9]" >
....
<input id="field_2" type="text" name="Item[fields][x]" >
so clicking
dup1, clone field[1] into [4],[7] ...[1+3(i)]
dup2, clone field[2] into [5],[8],...[2+3(i)]
dup3, clone field[3] into [6],[9],...[3+3(i)]
一貫性がないため、id値を使用できません.. year_league66134 などの値があります