Подключите нашего Telegram-бота для уведомлений о новых проектах
Требуется помощь js jQuery
Разместить заказ

f
Заказчик
Отзывы фрилансеров:
+ 4
- 0
Зарегистрирован на сайте 9 лет и 6 месяцев
Бюджет:
1500 ₽/час
Делаю так клон таблицы и меняю в ней id и name + 1:
var quantity = jQuery("tbody[id^="+nameTbody+"]").length;
quantity++;
jQuery("#"+nameTbody)
.clone(true)
.find( ':text,textarea,:submit' )
.attr( 'id', function() { return this.id.split('_')[0] + "_" + quantity; })
.attr( 'name', function(){ return this.name.split('_')[0] + "_" + quantity; })
//.val( "" )
.end()
.appendTo("#"+nameTable);
---- имею --
<input type="submit" class='input_ss' onclick="cloneRow('firstTable', 'input')" value="+">
<tr>
<td></td>
<td><input type="text" class="input" name="index_1" id="index_1" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='index_1'"></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type="text" class="input" name="apple_1" id="apple_1" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='apple_1'"></td>
</tr>
--- клон ----
<td></td>
<td><input type="text" class="input" name="index_2" id="index_2" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='index_1'"></td>
</tr>
<tr>
<td></td>
<td><input type="text" class="input" name="apple_2" id="apple_2" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='apple_1'"></td>
</tr>
----
задача: изменить в type="submit" onclick на this.form.action.value='index_2' и this.form.action.value='apple_2',
где _2 это порядковый номер id клонирования. Например index_3 apple_4 index_5.
Должно быть так:
<input type="submit" value=">" onclick="this.form.action.value='index_2'">
<input type="submit" value=">" onclick="this.form.action.value='apple_2'">
и так далее
Быстрое решение, быстрая оплата. Спасибо.
Клон идет (не те submit которые меняются/меняем):
<input type="submit" class='input_ss' onclick="cloneRow('firstTable', 'input')" value="+">
сейчас получаетмя так:
<input type="submit" value=">" onclick="this.form.action.value='index_1'" id="_2" name="_2">
var quantity = jQuery("tbody[id^="+nameTbody+"]").length;
quantity++;
jQuery("#"+nameTbody)
.clone(true)
.find( ':text,textarea,:submit' )
.attr( 'id', function() { return this.id.split('_')[0] + "_" + quantity; })
.attr( 'name', function(){ return this.name.split('_')[0] + "_" + quantity; })
//.val( "" )
.end()
.appendTo("#"+nameTable);
---- имею --
<input type="submit" class='input_ss' onclick="cloneRow('firstTable', 'input')" value="+">
<tr>
<td></td>
<td><input type="text" class="input" name="index_1" id="index_1" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='index_1'"></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type="text" class="input" name="apple_1" id="apple_1" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='apple_1'"></td>
</tr>
--- клон ----
<td></td>
<td><input type="text" class="input" name="index_2" id="index_2" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='index_1'"></td>
</tr>
<tr>
<td></td>
<td><input type="text" class="input" name="apple_2" id="apple_2" value=""></td>
<td><input type="submit" value=">" onclick="this.form.action.value='apple_1'"></td>
</tr>
----
задача: изменить в type="submit" onclick на this.form.action.value='index_2' и this.form.action.value='apple_2',
где _2 это порядковый номер id клонирования. Например index_3 apple_4 index_5.
Должно быть так:
<input type="submit" value=">" onclick="this.form.action.value='index_2'">
<input type="submit" value=">" onclick="this.form.action.value='apple_2'">
и так далее
Быстрое решение, быстрая оплата. Спасибо.
Клон идет (не те submit которые меняются/меняем):
<input type="submit" class='input_ss' onclick="cloneRow('firstTable', 'input')" value="+">
сейчас получаетмя так:
<input type="submit" value=">" onclick="this.form.action.value='index_1'" id="_2" name="_2">
Разделы:
Опубликован:
13.12.2024 | 14:46 [последние изменения: 13.12.2024 | 15:37]