Php jQuery确认框
我有一个循环,通过复选框进行输入,如果一切正常,它需要显示一个弹出框,询问用户是否可以继续并提交订单,如果不可以,则它不需要做任何事情(在内部处理) 我遇到了一些问题,不知道怎么做,有什么想法吗 这是我目前的密码Php jQuery确认框,php,jquery,Php,Jquery,我有一个循环,通过复选框进行输入,如果一切正常,它需要显示一个弹出框,询问用户是否可以继续并提交订单,如果不可以,则它不需要做任何事情(在内部处理) 我遇到了一些问题,不知道怎么做,有什么想法吗 这是我目前的密码 function validateSubmit(){ var r=true; $('tr').each( function() { // Find first input var input1 = $(th
function validateSubmit(){
var r=true;
$('tr').each( function() {
// Find first input
var input1 = $(this).find('input').eq(0);
var qty1 = input1.val();
// Find Second input
var input2 = $(this).find('input').eq(1);
var qty2 = input2.val();
// Find third input
var input3 = $(this).find('input').eq(2);
var qty3 = input3.val();
// Find select box
var selectBx = $(this).find('select');
var selectVal = selectBx.val();
if(qty1 === '' && selectVal != 'Please Select...') {
alert("You've chosen an option, but not entered a quantity to dispute, please check your inputs.");
r=false;return false;
}
if(qty1 != '' && selectVal === 'Please Select...') {
alert("You've entered a quantity, but not chosen why, please check your reasons.");
r=false;return false;
}
if (qty1 > qty2) {
alert("For one of your entries, the disputed quantity is larger than the shipped quantity.");
r=false;return false;
}
});
if (r==true) {
var a = confirm("Are you sure you want to confirm the dispute? You cannot edit this after it's been submitted?");
if (a==true)
{
return true;
}
else
{
return false;
}
}
});
HTML:
非常感谢你的帮助 回答:
function validateSubmit(){
var r=true;
$('tr').each( function() {
// Find first input
var input1 = $(this).find('input').eq(0);
var qty1 = input1.val();
// Find Second input
var input2 = $(this).find('input').eq(1);
var qty2 = input2.val();
// Find third input
var input3 = $(this).find('input').eq(2);
var qty3 = input3.val();
// Find select box
var selectBx = $(this).find('select');
var selectVal = selectBx.val();
if(qty1 === '' && selectVal != 'Please Select...') {
alert("You've chosen an option, but not entered a quantity to dispute, please check your inputs.");
r=false;return false;
}
if(qty1 != '' && selectVal === 'Please Select...') {
alert("You've entered a quantity, but not chosen why, please check your reasons.");
r=false;return false;
}
if (qty1 > qty2) {
alert("For one of your entries, the disputed quantity is larger than the shipped quantity.");
r=false;return false;
}
});
if (r=true) {
var a = confirm("Are you sure you wish to dispute? You cannot dispute this order again once submitted.");
return a;
}
}
答复:
function validateSubmit(){
var r=true;
$('tr').each( function() {
// Find first input
var input1 = $(this).find('input').eq(0);
var qty1 = input1.val();
// Find Second input
var input2 = $(this).find('input').eq(1);
var qty2 = input2.val();
// Find third input
var input3 = $(this).find('input').eq(2);
var qty3 = input3.val();
// Find select box
var selectBx = $(this).find('select');
var selectVal = selectBx.val();
if(qty1 === '' && selectVal != 'Please Select...') {
alert("You've chosen an option, but not entered a quantity to dispute, please check your inputs.");
r=false;return false;
}
if(qty1 != '' && selectVal === 'Please Select...') {
alert("You've entered a quantity, but not chosen why, please check your reasons.");
r=false;return false;
}
if (qty1 > qty2) {
alert("For one of your entries, the disputed quantity is larger than the shipped quantity.");
r=false;return false;
}
});
if (r=true) {
var a = confirm("Are you sure you wish to dispute? You cannot dispute this order again once submitted.");
return a;
}
}
好的,快速浏览一下就会发现嵌套的if(a==true)和else语句包含您不需要的额外确认。相反,你应该打电话来保存你的信息。在当前状态下,您的代码非常不完整。当用户确认他们确定后,您想做什么?对不起!!!我会很快编辑它,我只是在胡闹,试图从中获得一些输出!(现在编辑)看起来更好:)。现在,您要么返回true,要么返回false。那么你对这个反应做了什么?您遇到的“少数问题”是什么?我遇到的问题是,它似乎根本没有显示,它是否返回任何变量?是否在错误控制台中显示任何内容?请在JSFIDLE上设置一个带有相关HTML标记的示例。快速浏览一下就会发现嵌套的if(a==true)和else语句包含您不需要的额外确认。相反,你应该打电话来保存你的信息。在当前状态下,您的代码非常不完整。当用户确认他们确定后,您想做什么?对不起!!!我会很快编辑它,我只是在胡闹,试图从中获得一些输出!(现在编辑)看起来更好:)。现在,您要么返回true,要么返回false。那么你对这个反应做了什么?您遇到的“少数问题”是什么?我遇到的问题是,它似乎根本没有显示,它是否返回任何变量?是否在错误控制台中显示任何内容?请在JSFIDLE上设置一个带有相关HTML标记的示例。
function validateSubmit(){
var r=true;
$('tr').each( function() {
// Find first input
var input1 = $(this).find('input').eq(0);
var qty1 = input1.val();
// Find Second input
var input2 = $(this).find('input').eq(1);
var qty2 = input2.val();
// Find third input
var input3 = $(this).find('input').eq(2);
var qty3 = input3.val();
// Find select box
var selectBx = $(this).find('select');
var selectVal = selectBx.val();
if(qty1 === '' && selectVal != 'Please Select...') {
alert("You've chosen an option, but not entered a quantity to dispute, please check your inputs.");
r=false;return false;
}
if(qty1 != '' && selectVal === 'Please Select...') {
alert("You've entered a quantity, but not chosen why, please check your reasons.");
r=false;return false;
}
if (qty1 > qty2) {
alert("For one of your entries, the disputed quantity is larger than the shipped quantity.");
r=false;return false;
}
});
if (r=true) {
var a = confirm("Are you sure you wish to dispute? You cannot dispute this order again once submitted.");
return a;
}
}