0
我有一個註冊表單,我正在創建。在我的html文件,我有兩個單選框,如果一個無線電值是== 1,然後請求ajax
<input type="radio" name="whatever" value="0" id="whatever" checked//> No
<input type="radio" name="whatever" value="1" id="whatever"> Yes
如果該值爲1,應該用ajax發送電子郵件,這裏是我,
if($("input[name='whatever']").val()=='2'){
$.ajax({
type: 'POST',
url: base + 'email',
data: vData,
success: function() {
// alert("I'm the callback")
}
});
}
在此先感謝您的幫助。
呃,爲什麼兩個元素有相同的id? – hjpotter92 2012-04-12 22:11:19
ids應該是唯一的 - 你是問爲什麼if($(「input [name ='whatever']」)。val()=='2'){'不會觸發爲=='1' – mikevoermans 2012-04-12 22:11:29