这是您所要求的简化版本,它应该向您展示使用 jQuery 从页面获取值的基础知识:
HTML:
Select a Product: <select id="product">
<option>Photoshop CS6</option>
<option>Photoshop Elements</option>
<option>iPhoto</option>
</select><br>
Digital Download <input id="digitalDownload" class="options" type="checkbox"><br>
Student Discount <input id="studentDiscount" class="options" type="checkbox"><br>
<br>
<button id="add">Add to Order</button><br>
<br>
<div id="summary"></div>
Javascript:
$("#add").click(function() {
// gather current order info
var order = [];
order.push($("#product").val());
order.push("Digital Download: " + $("#digitalDownload").prop("checked"));
order.push("Student Discount: " + $("#studentDiscount").prop("checked"));
// put order info into summary
$("#summary").append("<div>" + order.join(", ") + "</div>");
// clear previous checked values
$(".options").prop("checked", false);
});
在这里工作演示:http: //jsfiddle.net/jfriend00/Rjmbx/