我有以下代码。当用户单击“添加另一项运动”时,我试图获取它,kpsport1 将根据用户单击的次数增加到 2、3、4 等。
此外,当他们选择一项运动时,我希望将“选择您的运动”(formSectionHeader)替换为他们选择的运动。尽管在 JS 部分工作了数天,但在使其正常工作时遇到了重大问题。欣赏任何见解!太感谢了!!
<div id="copy">
<div id="personalInfo">
<h1>Sporting Experience</h1>
<form action="" name="signUp-pg1" id="signUp-pg1">
<div class="singleSportWrap">
<h2 class="formSectionHeader"><strong>CHOOSE YOUR SPORT</strong> <span>you can add another sport later.</span></h2>
<div class="singleSport">
<div id="KPspecialityPosition" class="formSection">
<div id="sportSelectField" class="selectStyled">
<select class="longField styled KPsportSelecter" name="KPsport1" id="KPsport1">
<option value="default">Sport</option>
<option value="basketball">Basketball</option>
<option value="soccer">Soccer</option>
<option value="football">Football</option>
<option value="baseball">Baseball</option>
<option value="hockey">Hockey</option>
</select>
<div class="checkboxInput"><input type="checkbox" name="primarySport" value="primarySport"><span>This my primary sport</span></div>
</div><!-- //selectStyled -->
</div><!-- //formSection -->
</div><!-- //singleSport -->
</div><!-- //singleSportWrap -->
<p id="addAnotherSport" class="addMoreBtn">Add Another Sport</p>
<div id="formStepControls">
<a id="saveForm">Save for Later</a>
<a href="sign-up-3.php" id="proceedForm">Proceed to Vouching</a>
</div><!-- //formStepControls -->
</form>
</div><!-- personal info -->
</div><!-- copy -->