Я пытаюсь создать форму учетной записи с несколькими записями за раз.
<form id="addnewentry" name="addnewentry" method="post" action="main.php?s=entries&opt=addnew">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 entries">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 entrydiv" style="font-size:1.6em;border: 1px solid #000;" dir="rtl" id="klon">
<!--Test Div entrydiv -->
<div class="col-lg-2 col-md-12 col-sm-12 col-xs-12">
<h4>نوع القيد</h4>
<select id="acc_accounts_types" name="acc_accounts_types" class="form-control" style="font-size:15px;" required>
<?php echo $transtype;?>
</select>
</div>
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
<h4>من حساب</h4>
<select id="from_account_id" name="from_account_id" class="select2 form-control" required>
<?php echo $accounts;?>
</select>
</div>
<div class="col-lg-2 col-md-12 col-sm-12 col-xs-12 transaction_value">
<h4>مبلغ</h4>
<input type="number" step="0.01" id="transaction_value" name="transaction_value" value="" class="form-control testee" onchange="numtoletter(this);" onkeyup="numtoletter(this);" required />
</div>
<div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
<h4>إلى حساب</h4>
<select id="to_account_id" name="to_account_id" class="select2 form-control" required>
<?php echo $accounts;?>
</select>
</div>
<div class="col-lg-1 col-md-12 col-sm-12 col-xs-12">
<h4>Opt</h4>
<button id="add-new" name="add-new" class="btn btn-success btn-block" onclick="addingNewRow();" form="">
<span class="glyphicon glyphicon-plus"></span>
</button>
<button id="remove1" name="remove1" class="btn btn-danger btn-block" onclick="DelLastRow();" form="">
<span class="glyphicon glyphicon-minus"></span>
</button>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center tafqeetndesc">
<input type="text" id="tafqeet" name="tafqeet" value="" class="form-control" style="font-size:1.5em;display:none;" readonly />
<textarea id="transaction_description" name="transaction_description" class="form-control" style="min-width:100%;font-size:1.6em;" placeholder="وصف القيد"></textarea>
</div>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center" style="padding-bottom:30px;">
<button id="addnew" name="addnew" class="btn btn-success btn-block" type="submit" form="addnewentry">
<span class="glyphicon glyphicon-plus"></span><h5></h5><span style="font-size:20px; font-weight:900;">إضافة وحفظ</font>
</button>
</div>
</form>
И я пытаюсь использовать Javascript для добавления или удаления строк следующим образом:
function numtoletter(ce){
var target = $(ce).attr('id');
if ($('#transaction_value').val()){
if ($('#transaction_value').val() > 0){
$.get('<?php echo $_SESSION['appurl']; ?>includes/numtoletters.php?num=' + $('#transaction_value').val()).then(function(responseData) {
var loginresponse = responseData.search("===ERROR===");
if ((loginresponse == 0) || (loginresponse != -1)){
alert('يوجد خطأ في الحساب. تأكد من إدخال البيانات المطلوبة للحساب');
} else {
$('#tafqeet').val(responseData);
}
});
}else{
$('#tafqeet').val('صفر');
}
}else{
$('#tafqeet').val('');
}
}
function addingNewRow(){
$('.entrydiv').clone().appendTo('.entries');
}
function DelLastRow (){
$('.entries').find('.entrydiv:last').remove();
}
Функция «numtoletter» должна возвращать числа арабскими буквами.
Проблема в том, как настроить javascript для работы с несколькими строками.