提交/发送订单,参加2 [英] Submit/Firing Order, Take 2

查看:39
本文介绍了提交/发送订单,参加2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿JavaScript大师......


我要再试一次。我得到的帮助没有得到那么多的帮助

的风格< grin>。我很感激(用其他语言编写了很长一段时间来讨论

)每个人对于HOW事情应该如何完成都有自己的看法。但是,如果它没有帮助我弄清楚我的问题,请

请...(用你自己礼貌的方式说''节省带宽'')。


我的保存按钮的MouseUp中有代码(是的,从技术上来说它应该是

到表格的''OnSubmit()'',但我不是''我想这样做,因为我已经黑客攻击了一个预包装的课程(在VFP中)而且我不想成为

黑客一秒钟)。没有OnSubmit。在表单上(预先回答

a问题)。


在JavaScript函数中的其他所有内容我都在谈论,如果我陷阱

输入错误,我返回''false''并且表单没有提交。如果我

返回''true'',表单提交就好了。


但是,在例程的最后部分使用''确认()'' - 在一个

IF声明中。根据某人的提示,我将其从使用

变量改为简单地返回true或false。然而,它不起作用 -

就像变量不起作用一样。如果我返回一个假,表格

没有提交,但即使我返回一个真实的,表格也没有提交。


使用演绎推理,我在IF

语句中有确认()(这是其中唯一的内容),如果我这是完整的,那么我可以使用
不要输入IF,如果我这样做就行了,我想我可以将

问题缩小到确认()。


我只需要输入一个硬编码的document.form.submit(),除了

不能用后端VFP的东西我解释返回表格

变量。


其他人可以复制这个或者帮忙!?!?


我无法想象其他人有时候没有'以这种方式进行确认()?

可能是吗?代码贴在下面...


迷失在圣塔莫尼卡......(HELLLPPPP !!!)


- John Kiernan, KierPro Associates

自定义VFP /会计编程

和Web界面

VFP和/或SQL后端


函数cliservsave(){

lvIsnew = document.getElementById(''isnew'');

lvIsnewV = lvIsnew.value

lvRepf = document.getElementById(''repfreq'');

lvRepfV = lvRepf.value;

lvNotes = document.getElementById(''NOTES'');

lvNVal = lvNotes.value;

lvDue = document.getElementById(''duedate'');

lvDueV = lvDue.value;

lvNotComp = document.getElementById(''NOTCOMP'');

lvNCVal = lvNotComp.checked;


if(lvNVal ==" ;"&& lvNCVal == true){

alert(如果未完成,必须输入注释。);

返回false; < br $>
}


lvDescrip = document.getElementById(''DESCRIP'');

lvDVal = lvDescrip.value;

if(lvDVal ==""){

alert("描述不能为空。);

返回false;

}


if(lvNCVal == true&& (lvDueV!==""&& lvDueV!==" 01/01 / 00")){

alert("如果未完成,截止日期必须为空。 ");

返回false;

}


if(lvIsnewV ==" true"&& lvRepfV !==" None"){

返回确认(您确定要生成多条记录吗?)

}


返回true;

}

解决方案

2004年8月16日星期一16:57:41 GMT,John Kiernan< ki ******** @ verizon.net>

写道:

我打算试试这个再次。我没有得到任何有关风格< grin>的建议的帮助。我很感激(用其他语言编写了很长一段时间),每个人都对如何完成事情有自己的看法。但是,如果它没有帮助我解决我的问题,请...(填写你自己的礼貌方式来说'''节省带宽'')。


对于手腕上的耳光很抱歉,但是...


我想花点时间指出这一点小组是一个讨论

的论坛。它不是服务台。如果讨论碰巧与你一起提供给你,海报,答案,而且通常会这样,

很棒。如果没有,请向某人寻求答案。毕竟,你得到我们的帮助

免费,你得到你支付的[1]。


[snip]

在JavaScript函数中的其他所有内容我都在谈论,如果我陷入输入错误,我会返回一个''false''并且表单不会提交。
如果我返回''true'',表单提交就好了。




您是否在多个浏览器中对此进行了测试?它有所作为吗?

回答这些问题并不是真的有帮助,但它可能会对未来的其他人产生帮助。


由于提示此确认的测试不依赖于除了两个控件的值之外的任何其他内容,您是否考虑过移动

确认以更改事件放在有问题的控件上。

这意味着不会干扰mouseup事件,并且不可能调用浏览器错误
。最好确保

确认只发生一次。


当然,最好的办法是在

服务器要求确认,以便无JavaScript用户不会在不知不觉中绕过它。当然,如果这不是网络,那就没有

需要。


[snip]
<祝你好运,祝你好运,

迈克

[1]实际上,在这里常客的质量,你很可能会得到>
比你能支付的更好。


-

Michael Winter

替换.invalid ;与.uk通过电子邮件回复


积分......


我想在这一点上,这个帖子会变得更多a''抬起头来'

每个人,因为我很确定答案是:


不要放任何东西一个MouseUp(或MouseDown)事件在提交()之前立即来了
!"


我为什么这么说?简单......


我制作了一个包含ONE元素的HTML表单,一个提交按钮。在那个按钮上

我把一个OnMouseUp()调用放到一个.js文件中,只调用了一个confirm()

框。当我运行它时,它无论用户

选择了什么都颠覆了submit()。然后我取出confirm()并发出警报()。它也是
实现同样的事情(无论函数返回什么)。


答案:不要使用Alert()或Dialog( )执行

提交的按钮()!

下面为法医分析提供的代码...


- John Kiernan,KierPro Associates

自定义VFP /会计编程

和Web界面

VFP和/或SQL后端


HTML来源:

< html>

< head>

< meta http-当量= QUOT;内容类型"含量=" text / html的; charset = windows-1252">

< script language =" JavaScript" src =" c:\test.js">< / script>

< / head>

< body>

< form action =" http://www.nytimes.com/pages/aponline/news/index.html"

method =" POST">

< p>< input type =" submit"值= [提交" name =" B1"

OnMouseUp = mousetest()>< / p>

< / form>

< /正文>

< / html>


JS来源(test.js):

function mousetest(){

// alert(这是一个测试);

//返回true;

返回确认(你确定要吗?生成多个记录?

}


您将发布表格标签的代码,John。


一些人已经向你强调了这一点。我的猜测是你没有在表格标签中指定的

动作属性。也许是一个天真的猜测,但是我们要确定
确实需要表单html标签和按钮html代码,因为它们在你的页面中显示为

,以使其更有效猜测。

确认retgurning false不应该提交表格。然而,它还取决于你的表格标签是如何制作的。


另外,你有没有尝试过更简单的东西:


function cliservsave(){

alert(" hallo");返回false; // FALSE

}


然后

函数cliservsave(){

alert (QUOT;喂");返回true; // TRUE

}


然后

函数cliservsave(){

返回确认(QUOT;喂"); // TRUE或FALSE

}


这个微不足道的调试可能看起来非常幼稚,但它是唯一可以

的东西告诉你,你有什么问题

1)在表格标签中

2)除了返回陈述之外的其他东西 - 如果那些简单的片段

在_your_platform上工作,然后问题是_not_在返回中。这是一个重要的蓝图,可以确定你为什么这些琐事可以很重要。


让我们发布,ciao

Alberto
http://www.unitedscripters.com/


然而,在例程的最后部分使用''确认()'' - 在
和IF之内声明。根据这里某人的提示,我将它从
改为使用变量简单地返回true或false。然而,它并不是b $ b b工作 - 就像变量不起作用一样。如果我返回虚假,表格
不提交,但即使我返回真实,表格也不提交。

使用演绎推理,我有在IF
声明中确认()(并且这是其中唯一的内容)并且如果
我没有输入IF并且它没有如果我做的话 ,我想我可以将
问题缩小到确认()。

我只需要输入一个硬编码的document.form.submit(),除了
不不能使用后端VFP的东西我解释返回
表格变量。

其他人可以复制这个或帮助!?!?

我无法想象其他人有时没有以这个
的方式进行确认()?可能吗?代码贴在下面......

迷失在圣莫尼卡......(HELLLPPPP !!!)

- John Kiernan,KierPro Associates
自定义VFP /会计编程和Web界面
VFP和/或SQL后端

函数cliservsave(){
lvIsnew = document.getElementById(''isnew'') ;
lvIsnewV = lvIsnew.value
lvRepf = document.getElementById(''repfreq'');
lvRepfV = lvRepf.value;
lvNotes = document.getElementById(''NOTES '');
lvNVal = lvNotes.value;
lvDue = document.getElementById(''duedate'');
lvDueV = lvDue.value;
lvNotComp = document.getElementById (''NOTCOMP'');
lvNCVal = lvNotComp.checked;

if(lvNVal ==""&& lvNCVal == true){
警报(如果未完成,则必须输入注释。;
返回false;
}
lvDescrip = document.getElementById(' DESCRIP'');
lvDVal = lvDescrip.value;
if(lvDVal ==""){
alert(" Description Can not Blank。);
返回false;
}
if(lvNCVal == true&& (lvDueV!==""&& lvDueV!==" 01/01 / 00")){
警告(如果未完成,截止日期必须为空白。);
返回false;
}
if(lvIsnewV ==" true"&& lvRepfV!==" None"){
返回确认( 你确定要生成多个记录吗?
}

返回true;
}



Hey JavaScript gurus...

I''m going to try this again. I haven''t gotten as much help as I have advice
on style<grin>. I appreciate (having programmed in other languages for
quite a while) that everyone has their own opinion on HOW things should be
done. However, if it does not comes AFTER helping me figure out my problem,
please... (fill in your own polite way to say ''save the bandwidth'').

I have code in a MouseUp of my save button (yes, technically it should go
into the ''OnSubmit()'' of the form, but I don''t want to do that, because I''m
already hacking one pre-packaged class (in VFP) and I don''t want to be
hacking a second). There is NO "OnSubmit" on the form itself (to pre-answer
a question).

On everything else in the JavaScript function I''m talking about, if I trap
for an input error, I return a ''false'' and the form doesn''t submit. If I
return a ''true'', the Form submits just fine.

However, on the last part of the routine utilizes a ''Confirm()'' -- within an
IF statement. As per a hint from someone here, I changed it from utilizing
a variable to simply returning a true or false. However, it doesn''t work --
in the same way the variable didn''t work. If I return a false, the form
doesn''t submit, but even if I return a true, the form doesn''t submit.

Using deductive reasoning in that I have the Confirm() within an IF
statement (and it''s the only thing within it) and the whole thing works if I
don''t enter the IF and it DOESN"T work if I do, I think I can narrow the
problem down to the Confirm().

I would simply put in a hard coded document.form.submit(), except that
doesn''t work with the back end VFP stuff I have interpreting the return form
variables.

Can anyone else duoplicate this or help!?!?

I can''t imagine someone else sometime hasn''t put in a confirm() in this way?
Could it be? Code pasted in below...

Lost in Santa Monica.... (HELLLPPPP!!!)

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends

function cliservsave() {
lvIsnew = document.getElementById(''isnew'');
lvIsnewV = lvIsnew.value
lvRepf = document.getElementById(''repfreq'');
lvRepfV = lvRepf.value;
lvNotes = document.getElementById(''NOTES'');
lvNVal = lvNotes.value;
lvDue = document.getElementById(''duedate'');
lvDueV = lvDue.value;
lvNotComp = document.getElementById(''NOTCOMP'');
lvNCVal = lvNotComp.checked;

if (lvNVal == "" && lvNCVal == true) {
alert("If Not Completed, Notes MUST be entered.");
return false;
}

lvDescrip = document.getElementById(''DESCRIP'');
lvDVal = lvDescrip.value;
if (lvDVal == "") {
alert("Description Cannot be Blank.");
return false;
}

if (lvNCVal == true && (lvDueV !== "" && lvDueV !== "01/01/00") ) {
alert("If Not Completed, Due Date must be Blank.");
return false;
}

if (lvIsnewV == "true" && lvRepfV !== "None") {
return confirm("Are you sure you want to generate multiple records?")
}

return true;
}

解决方案

On Mon, 16 Aug 2004 16:57:41 GMT, John Kiernan <ki********@verizon.net>
wrote:

I''m going to try this again. I haven''t gotten as much help as I have
advice on style<grin>. I appreciate (having programmed in other
languages for quite a while) that everyone has their own opinion on HOW
things should be done. However, if it does not comes AFTER helping me
figure out my problem, please... (fill in your own polite way to say
''save the bandwidth'').
Sorry for the slap on the wrist, but...

I''d like to take a moment to point out that this group is a forum for
discussion. It is not a help desk. If the discussion happens to coincide
with providing you, the poster, with an answer, and it usually does,
great. If not, pay someone for answers. After all, you''re getting our help
for free and you get what you pay for[1].

[snip]
On everything else in the JavaScript function I''m talking about, if I
trap for an input error, I return a ''false'' and the form doesn''t submit.
If I return a ''true'', the Form submits just fine.



Have you tested this in more than one browser? Did it make a difference?
Answering those questions won''t really help, but it might help others in
future.

As the test that prompts this confirmation doesn''t depend on anything
other than the value of two controls, have you thought of moving the
confirmation to change events that are placed on the controls in question.
That would mean no interference with the mouseup event, and no possibility
of invoking browser bugs. It would be best to make sure that the
confirmation only occurs once.

Of course, the better thing to do is place an intermediary step on the
server that asks for confirmation so that JavaScript-less users don''t
bypass it unknowingly. Of course, if this isn''t for the Web, there''s no
need for that.

[snip]

Good luck,
Mike
[1] Actually, with the quality of the regulars here, you''re likely to get
better than what you could pay for.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail


Points taken...

I think at this point, this thread will become more of a ''heads up'' to
everyone, because I''m pretty sure the answer is:

"Don''t put anything in a MouseUp (or MouseDown) event that comes
immediately before a submit()!"

Why do I say that? Simple...

I made an HTML form with ONE element in it, a submit button. On that button
I placed a OnMouseUp() call to a .js file with only a call to a confirm()
box. When I ran it, it subverted the submit() no matter what the user
chose. I then took out the confirm() and put in an alert(). It also
achieves the same thing (regardless of what the function returns).

Answer: don''t use an Alert() or a Dialog() on the button that performs the
submit()!

Code provided below for forensic anaylsis...

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends

HTML Source:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script language="JavaScript" src="c:\test.js"></script>
</head>
<body>
<form action="http://www.nytimes.com/pages/aponline/news/index.html"
method="POST">
<p><input type="submit" value="Submit" name="B1"
OnMouseUp=mousetest()></p>
</form>
</body>
</html>

JS Source (test.js):
function mousetest() {
// alert("This is a test");
// return true;
return confirm("Are you sure you want to generate multiple records?")
}


You''d post the code of the form tag, John.

A few already stressed this to you. My guess is that you don''t have an
action property specified in the form tag. Maybe a naive guess but we''d
really need the form html tag and the button html codes too, as they appear
in your page, to make a more valid guess.
A confirm retgurning false should not submit the form. Yet it depends too on
how your form tag is crafted.

Also, have you tried a simpler thing:

function cliservsave(){
alert("hallo"); return false;//FALSE
}

then
function cliservsave(){
alert("hallo"); return true;//TRUE
}

then
function cliservsave(){
return confirm("hallo"); //TRUE or FALSE
}

This trivial debugging may seem terribly naive and yet it is the only thing
that can tell you whther you have a problem
1) in the form tag
2) in something else than the return statements - if those simple snippets
work on _your_platform, then the problem is _not_ in the returns. It is an
important blueprint to ascertain you sede why those trivialities can be
important.

keep us posted, ciao
Alberto
http://www.unitedscripters.com/


However, on the last part of the routine utilizes a ''Confirm()'' -- within an IF statement. As per a hint from someone here, I changed it from utilizing a variable to simply returning a true or false. However, it doesn''t work -- in the same way the variable didn''t work. If I return a false, the form
doesn''t submit, but even if I return a true, the form doesn''t submit.

Using deductive reasoning in that I have the Confirm() within an IF
statement (and it''s the only thing within it) and the whole thing works if I don''t enter the IF and it DOESN"T work if I do, I think I can narrow the
problem down to the Confirm().

I would simply put in a hard coded document.form.submit(), except that
doesn''t work with the back end VFP stuff I have interpreting the return form variables.

Can anyone else duoplicate this or help!?!?

I can''t imagine someone else sometime hasn''t put in a confirm() in this way? Could it be? Code pasted in below...

Lost in Santa Monica.... (HELLLPPPP!!!)

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends

function cliservsave() {
lvIsnew = document.getElementById(''isnew'');
lvIsnewV = lvIsnew.value
lvRepf = document.getElementById(''repfreq'');
lvRepfV = lvRepf.value;
lvNotes = document.getElementById(''NOTES'');
lvNVal = lvNotes.value;
lvDue = document.getElementById(''duedate'');
lvDueV = lvDue.value;
lvNotComp = document.getElementById(''NOTCOMP'');
lvNCVal = lvNotComp.checked;

if (lvNVal == "" && lvNCVal == true) {
alert("If Not Completed, Notes MUST be entered.");
return false;
}

lvDescrip = document.getElementById(''DESCRIP'');
lvDVal = lvDescrip.value;
if (lvDVal == "") {
alert("Description Cannot be Blank.");
return false;
}

if (lvNCVal == true && (lvDueV !== "" && lvDueV !== "01/01/00") ) {
alert("If Not Completed, Due Date must be Blank.");
return false;
}

if (lvIsnewV == "true" && lvRepfV !== "None") {
return confirm("Are you sure you want to generate multiple records?")
}

return true;
}



这篇关于提交/发送订单,参加2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆