誰かが下からフォームデータを収集するのを手伝ってくれませんか. 次のマークアップは、フォームからデータを正常に抽出するのに苦労していますが、x 人の顧客に対して検索されます。
どうもありがとう、ジェームズ
<h5 id="Customer1">
<span>Customer 1</span>
</h5>
<div class="CustomerWrapper">
<input type="hidden" value="0" id="CustomerType0" name="CustomerType0">
<span class="TitleSelect">
<label for="CustomerTitle0">Title</label>
<select id="CustomerTitle0" name="CustomerTitle0">
<option value="-1"></option>
<option value="1">Mr</option>
<option value="2">Mrs</option>
<option value="3">Ms</option>
<option value="4">Miss</option>
</select>
</span>
<span class="FirstInput">
<label for="FirstName0">First Name</label>
<input type="text" value="" name="FirstName0" id="FirstName0">
</span>
<span class="LastInput">
<label for="LastName0">Surname(s)</label>
<input type="text" value="" name="LastName0" id="LastName0">
</span>
姓と名だけが必要なため、私の試みはうまくいきません。
$('.PaxDetails .CustomerWrapper').each(function (index) {
var counter = ++index;
var firstName = "#FirstName" + counter;
var lastName = "#LastName" + counter;
var customerName = $(firstName).val() + ' ' + $(lastName).val();
alert(customerName);
});