jsp:
<label class="control-label" style="width: 100px">请假事由:</label>
<input name="radio" type="radio" class="raido-btn" id="shijia" value="coral1" />
<label for="coral1">事假</label>
<input name="radio" type="radio" class="raido-btn" id="bingjia" value="coral2" />
<label for="coral2">病假</label>
<label>其它:<input name="cause1" id="cause1" type="text" style="font-size: 14px;width:246px;"></label>
ajax:function shenqing() {
/*单选按钮的监听 */
var cause;
if($('#shijia').prop('checked')){
cause = '事假';
}
else if($('#coral2').prop('checked')){
cause = '病假';
}
else {
cause = $("#cause1").val();
}
$.ajax({
url : "../user/shenqing",
type : "post",
data : {
"cause" : cause;
},
async : false,
datatype : 'json',
success : function(data) {
var status = data.status;
if (status == 1) {
alert("插入成功! ");
}
}
})
}