我正在使用它將幾個字段的值收集到一個字段中。除單選按鈕值之外,所有內容都正確傳遞。選定的單選按鈕值未與JQuery傳遞
jQuery('#donate-form').submit(function() {
jQuery('[name="COMMENT2"]').val('Donation: ' + jQuery('.active [name="USER2"]').val() + ': ' + jQuery('input[name="reason"]:checked').val() + ': ' + jQuery('[name="sponsorName"]').val() +
' Occasion: ' + jQuery('.active [name="occasion"]').val() + ' Donated By: ' + jQuery('.active [name="donatedBy"]').val() + ' Use: ' + jQuery('input[name="day"]:checked').val() +
' Date: ' + jQuery('[name="date"]').val() + ' Contact Me: ' + jQuery('[name="contactMe"]').val());
});
HTML
<div class="row"><label for="amount">Amount:</label><input id="amount 2" name="AMOUNT" type="text" class="required"/><br/></div>
<div class="row">
<input name="reason" type="radio" id="memory" value="In Memory of" /><label for="memory">In Memory of</label>
<input name="reason" type="radio" id="honor" value="In Honor of"/><label for="honor">In Honor of</label>
<input name="reason" type="radio" id="noOccasion" value="No Occasion"/><label for="noOccasion">No Occasion</label>
<br/></div>
<div class="row"><label for="sponsorName">Name(s):</label>
<input id="sponsorName" name="sponsorName" type="text"/><br/></div>
<div class="row"><label for="occasion">Occasion:</label>
<input id="occasion" name="occasion" type="text"/><br/></div>
<div class="row"><label for="donatedBy">Donated By:</label>
<input id="donatedBy" name="donatedBy" type="text"/><br/></div>
<div class="row">Make a request to reserver your special day:</div>
<div class="row">
<input name="day" type="radio" id="English" value="English Date"/>
<label for="English">English Date</label>
<input name="day" type="radio" id="Hebrew" value="Hebrew Date"/>
<label for="Hebrew">Hebrew Date</label>
</div>
<div class="row"><label for="date">Date:</label>
<input id="date" name="date" type="text"/><br/></div>
<div class="row"><input type="checkbox" name="contactMe" value="yes" id="contactMe" /><label class="long" for="contactMe">Contact me for acknowledgement notices.</label></div>
<div class="row"><label for="comments">Comments</label><textarea id="comments" name="COMMENT1" cols="38" rows="1" style="margin-left:0"></textarea></div>
<input type="hidden" name="COMMENT2" value=""></input><input type="hidden" name="DESCRIPTION"></input>
</form>
請更好地格式化代碼,這是荒謬的 –
我認爲這是一個人們互相幫助的論壇。請解釋一下這有什麼荒謬的。 – user1413248
您似乎並未一直使用縮進或換行符。這不是很好的格式,但我在這裏看到更糟糕的,所以不要太親自... –