很抱歉再问一个简单的问题,但程序很难,就像他们说从不害怕问。 我想要做的是让jquery检测复选框是否已被点击,然后当用户点击发送按钮时,它将转到PHP说明是否已经检查过。
我有表格数据要处理到PHP,例如文本字段,但检查字段似乎不想工作。
我试过谷歌搜索我没有找到任何东西
这是代码
$(document).ready(function () {
// Make a function that returns the data, then call it whenever you
// need the current values
function getData() {
return {
login_username: $('#login-username').val(),
login_password: $('#login-password').val(),
remember_me: $('#remember_me').find(":checked").val()
}
}
$(":checkbox").click(function(){
$("#remember_me").text(this.value)
})
$('#login_content').hover(function() {
$(this).css("background-color", "transparent");
});
$('#login_content').mouseleave(function() {
$(this).css("background-color", "white");
});
$('.error').hover(function() {
$(this).css("background-color", "transparent");
});
$('.notice').hover(function() {
$(this).css("background-color", "transparent");
});
$('#login_content').mouseleave(function() {
$('.error').css("background-color", "#ffecec");
$('.notice').css("background-color", "#e3f7fc");
});
$(window).load(function(){
$('#background_cycler').fadeIn(1500);//fade the background back in once all the images are loaded
// run every 7s
setInterval('cycleImages()',4000);
})
function loading(e) {
$('#login_try').show();
}
function hide_loading(e) {
$('#login_try').hide();
}
function success_message(e) {
$('#success_login').html("We're Just Signing You In");
}
function clearfields() {
$('#login-username').val(''); //Clear the user login id field
$('#login_password').val(''); //Clear the user login password field
}
function check(e) {
e.preventDefault();
$.ajax({
url: 'check.php',
type: 'post',
error: function () {
//If your response from the server is a statuscode error. do this!!!
clearfields();
},
beforeSend: function () {
loading(e);
},
data: {
login_username: $('#login-username').val(),
login_password: $('#login-password').val(),
}, // get current values
success: function (data) {
//if your response is a plain text. (e.g incorrect username or password)
hide_loading(e);
if(data.indexOf("<b>Welcome Back</b>") > -1) {
hide_loading(e);
success_message(e);
}
if(data.indexOf("You're Already Signed In!") > -1) {
alert('This operation could not be proceeded');
}
$('#loading').fadeOut();
$('#content').hide();
$('#content').fadeIn(1000).html(data);
}
});
}
// Don't repeat so much; use the same function for both handlers
$('#field').keyup(function (e) {
if (e.keyCode == 13) {
var username = $('#login-username').val();
check(e);
}
});
$('#submit_login').click(function (e) {
if (e.keyCode != 13) {
check(e);
}
});
});
答案 0 :(得分:0)
var isChecked = ($("#check_box_id").is(':checked')) ? 1 : 0;
//send this variable to the php file.