我们直接看例子吧:
<input type="radio" name="radio" value="${var.id }" checked="checked"/>${var.contact } ${var.address } ${var.phone } ${var.postalCode }
<input type="radio" name="radio" value="${var.id }" checked="checked"/>${var.contact } ${var.address } ${var.phone } ${var.postalCode }
<input type="radio" name="radio" value="${var.id }" checked="checked"/>${var.contact } ${var.address } ${var.phone } ${var.postalCode }
//获取一组name为radio的单选按钮
var sellerAddr = document.getElementsByName("radio");
for(var i=0; i<sellerAddr.length; i++){
if(sellerAddr[i].checked==true){ //该单选按钮选中
$("#sellerAddrId").val(sellerAddr[i].value);
}
}
//下拉框选中问题
<td align="left">
<select id="selected">
<c:forEach items="${serviceList }" var="var">
<option value="${var.store.id }">${var.store.name }</option>
</c:forEach>
</select>
</td>
var storeId = $("#selected option:selected").val();
//获取选中的option的值