0

我正在使用它将几个字段的值收集到一个字段中。除单选按钮值外,所有内容均已正确传递。

 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>
4

1 回答 1

0

这段代码什么时候运行?假设您只想要检查的值,您尝试从单选按钮获取值的方式应该可以工作......

我在这里设置了一个基本演示显示这一点。只需单击“英文日期”单选按钮即可查看它的运行情况。

于 2012-09-12T18:52:53.153 回答