Я хотел бы получить все данные из таблицы HTML, которая заполняется из различных раскрывающихся списков. Я могу успешно отправить по электронной почте все поля ввода, но не могу понять, как получить данные JSON.
Я преобразовал данные таблицы в JSON, и переменная регистрируется нормально. Внутренняя база данных отсутствует, и все данные находятся на стороне клиента и находятся c HTML.
HTML
<div class="row">
<h4 class="info-text"> Tell us about yourself and the project you are working on.</h4>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Contact Name <small></small></label>
<input name="name" type="text" class="form-control" placeholder="Contact Name..." id="name">
</div>
<div class="form-group">
<label>Contact Number <small></small></label>
<input name="phone" type="text" class="form-control" placeholder="Number..." id="number">
</div>
</div>
<div class="col-sm-5 ">
<div class="form-group">
<label for="project">Please tell us a little about the project you are working on <small></small></label>
<textarea class="form-control" name="project" rows="5" id="project"></textarea>
</div>
</div>
<div class="col-sm-10 col-sm-offset-1">
<div class="form-group">
<label>Email <small></small></label>
<input name="email" type="email" class="form-control" placeholder="email@email.com" id="email">
</div>
</div>
<div class="col-sm-10 col-sm-offset-1">
<div class="form-group">
<label>Upload a file should you wish to</label>
<input name="file" type="file" class="btn btn-info" placeholder="email@email.com">
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Product</th>
<th scope="col">Ancillary Quantity</th>
<th scope="col">Fire Rating</th>
<th scope="col">Void Gap (mm)</th>
<th scope="col">Cut Type</th>
<th scope="col">Quantity</th>
<th scope="col">Bracket Finish</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
Вот l oop для jQuery для данных таблицы
$("#next").click(function () {
var table = $("table tbody");
table.find('tr').each(function (i) {
var $tds = $(this).find('td')
product = $tds.eq(1).text(),
aNum = $tds.eq(2).text(),
firerating = $tds.eq(3).text(),
voidgap = $tds.eq(4).text(),
sizetype = $tds.eq(5).text(),
numofeither = $tds.eq(6).text(),
brackets = $tds.eq(7).text();
// do something with productId, product, Quantity
var myJson = JSON.stringify('Row ' + (i + 1) + '\nProduct: ' + product +
'\nAncillary Quantity: ' + aNum +
'\nFire Rating: ' + firerating +
'\nVoid Gap: ' + voidgap +
'\nCut Type: ' + sizetype +
'\nQuantity: ' + numofeither +
'\nBrackets: ' + brackets);
console.log(myJson);
});
});
PHP Запрос
public function rules()
{
return [
'name' => 'required',
'phone' => 'required',
'email' => 'required|email',
'project' => 'required',
'row' => 'required',
];
}
Любая помощь по этому вопросу будет принята с благодарностью, я потратил несколько часов в поисках помощи безрезультатно.
Заранее спасибо