473,698 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit/Firing Order, Take 2

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.s ubmit(), 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.getEle mentById('isnew ');
lvIsnewV = lvIsnew.value
lvRepf = document.getEle mentById('repfr eq');
lvRepfV = lvRepf.value;
lvNotes = document.getEle mentById('NOTES ');
lvNVal = lvNotes.value;
lvDue = document.getEle mentById('dueda te');
lvDueV = lvDue.value;
lvNotComp = document.getEle mentById('NOTCO MP');
lvNCVal = lvNotComp.check ed;

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

lvDescrip = document.getEle mentById('DESCR IP');
lvDVal = lvDescrip.value ;
if (lvDVal == "") {
alert("Descript ion 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;
}
Jul 23 '05
13 1756
AHA!!!!!!!!!!!! !!!!

No more calls!!! We *have* a winner!!!

Thank you Richard! Thank You! Thank You! Thank You! Thank You! Thank
You!

The answer was I need to do what Richard said:
OnMouseUp="retu rn mousetest();"
Instead of what I was doing:
OnMouseUp="mous etest();"

It was running the function, but not RETURNing the value I was sending
back!!!!

(Even though I'm a novice to JS, I really should have known better!)

Thanks again to all who answered....

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends
"Richard Cornford" <Ri*****@litote s.demon.co.uk> wrote in message
news:cf******** ***********@new s.demon.co.uk.. . John Kiernan wrote:
<snip>
<p><input type="submit" value="Submit" name="B1"
OnMouseUp=mouse test()></p>

<snip>

The string value provided for an event handling attribute in HTML is
used by the browser to create a function that is assigned to a property
of the corresponding element within the DOM. Disregarding any provision
of custom scope chains that may be made by the browser, the above
onMouseUp handler is equivalent to:-

document.forms[0].elements['B1'].onmouseup = function(){
mousetest();
}

- executed with javascript. Thus the function object that represents the
event handling method of the submit button is a function that calls
another function, but returns no value. As a result it doesn't matter
much what the - mousetest - function returns as the event handler is not
passing that value on. It cannot cancel the event (unless the
proprietary returnValue property of the event object were set (on IE))
and so whatever default action follows from the event will happen.

A more viable formulation would be:-

OnMouseUp="retu rn mousetest();"

- so the value returned from - mousetest - is also returned form the
actual event handler. (note that the attribute value should be quoted as
it contains characters that are not allowed in an unquoted value
(according to the HTML specification). Validating the HTML would have
pointed that out, and valid HTML is a considerable aid in easy and
reliable scripting as it results in a consistently structured DOM that
is not subject to the vagaries of HTML error-correction.)

Richard.

Jul 23 '05 #11
This depends on the fact that like, if I am not mistaken Michael told you,
a few very good guys loiter here :-)
No I don't surreptitiously put myself in the pack LOL, but it is always
BEAUTIFUL to see constructive answers that lead to sove a problem fo a
person. I like when this happens, no matter whose was the answer.

if you consider how good the group can be when persons mind only to answer
questions and not to make silly rebuttals (in the past happened), you really
realize that the quality, also human here, can be interesting. Persons that
fought with javascript for years pop in here :-) N ever dismiss these guys,
all of a sudden can make the difference lol.

And now say thank you again to Richard :-) - *joking*

ciao, good luck!
Alberto
http://www.unitedscripters.com/
"John Kiernan" <ki********@ver izon.net> ha scritto nel messaggio
news:7N******** ********@nwrddc 04.gnilink.net. ..
AHA!!!!!!!!!!!! !!!!

No more calls!!! We *have* a winner!!!

Thank you Richard! Thank You! Thank You! Thank You! Thank You! Thank
You!

The answer was I need to do what Richard said:
OnMouseUp="retu rn mousetest();"


Instead of what I was doing:
OnMouseUp="mous etest();"

It was running the function, but not RETURNing the value I was sending
back!!!!

(Even though I'm a novice to JS, I really should have known better!)

Thanks again to all who answered....

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends
"Richard Cornford" <Ri*****@litote s.demon.co.uk> wrote in message
news:cf******** ***********@new s.demon.co.uk.. .

(snip)
Jul 23 '05 #12
John Kiernan wrote:
<snip>
The answer was I need to do what Richard said:
OnMouseUp="retu rn mousetest();"


Instead of what I was doing:
OnMouseUp="mous etest();"

It was running the function, but not RETURNing the
value I was sending back!!!!

<snip>

It was more 'an answer' than "the answer", in the sense that it
addressed a critical flaw in the original implementation. The other
suggestions made in relation to this question are still very valid,
particularly where they question the choice of event handler. If you use
a onmouseup event you are creating something that is pointing device
dependent. That would be in direct opposition to the recommendations of
the Web Content Accessibility Guidelines, where it is recommended that
functionality should be device independent (and so may have legal
implications in some jurisdictions/contexts).

However, mouse centred functionality is probably not a good idea in any
case. While it seems common for individuals who almost exclusively use
the mouse themselves for this type of task to assume that everyone else
does likewise, in practice individuals interact with computers in very
varied ways, depending on their circumstances and experience. For
example, it was my observation that numerous colleagues who had been
issued with IBM laptops found the pointing device on that machine so
inconvenient that they learnt all of the keyboard shortcuts, and having
learnt them they used them on any computer, and individuals who can
touch-type also appear to be significantly more inclined to be using
keyboard navigation.

Whatever you are doing the chances are good that at some point it will
be used by someone who uses the keyboard to interact with the browser
(entirely or in part) and when they do they will bypass your onmouseup
event handler.

Suggestions that - onclick - might be a better handler are valid, as it
is usually triggered by keyboard activation in addition to with the
mouse, but in my opinion the - onsubmit - handler of the form element is
the ideal place to be validating form content, and cancelling the
submission if need be. It has the advantages of being very well
supported, and intercepting attempts to submit a form by any means or
device (with the exception of code directly calling the form's -
submit - method, but that is always a bad idea).

The - onsubmit - handler has a direct relationship with the action that
is of interest in form validation.

Richard.
Jul 23 '05 #13
Dear Richard (et al) -
Yes, you're all right that if this was a public application, I should be
flogged in the public square for this. However, it's a private, company
wide system (accessed by nurses who work for the company, often from home
and at various 'homes' for the disabled).

As a result, we have the ability to dictate certain things, like they HAVE
to use IE (for the specific DHTML we use). We use a dynamic (rights driven
and built) JavaScript menu navigation system -- so if you don't have
scripting turned on, you ain't doing nuthin'.

As the script is an adjunct to the server side, which has a mirror of the
validation, I'm just trying to cut down on the traffic and 'round tripping'
by validating on the client.

As a geek in other areas -- and one who posts and monitors other boards
that help newbies in my area, I have noticed (and am guilty of it myself
some times) that we geeks tend to want show our knowledge and great brains
more than answer the question as asked. As a result, the poster (me, in
this case) has to come back again and again to 'explain himself'.

As I said... I am as guilty of this as anyone, but I -- for one -- am
going to try to be more cognizant of this in the future.

Thanks again Richard!
-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends
"Richard Cornford" <Ri*****@litote s.demon.co.uk> wrote in message
news:cf******** ***********@new s.demon.co.uk.. .
<snip>
It was more 'an answer' than "the answer", in the sense that it
addressed a critical flaw in the original implementation. The other
<snip>

Jul 23 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
17851
by: shake | last post by:
I have to develop an application sounds like this:- User is allow to access a form (is actually a test/quiz) within a specific time frame, let say 45 minutes. After this 45 minutes, if the user has not yet click the submit button to submit the form, the system need to automatically submit it. So, can anyone teach me how to check the time out as well as how to make the form submit automatically? Thank you very much.
4
4293
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field that has been modified/clicked the form doesn't always submit. When it does work, a Stored procedure is passed form variables and updates to the db are made. When it doesn't, its as if the form wasn't submitted, it reloads and resets the page, but...
0
2578
by: KathyB | last post by:
Hi, as you can see from my many posts the past few days, I have certainly been confused about the firing/non-firing of my textboxes and buttons. In addition to the explanations I've received from this group, I also came across a pretty good explanation of "Using the Enter key to submit a form" which describes the events created by the asp controls in html, etc. For anyone interested, here it is: http://www.allasp.net/enterkey.aspx ...
4
5586
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer postback. I.e. the button does go disabled, but the form does not invoke submit() method. Of course, it does work fine without this property. Clues?
1
1445
by: mazdotnet | last post by:
Hi guys, I have the following <form name="formpurchase" id="formpurchase" method=postaction="https://site.cgi"> <input type=hidden name="MerchantNumber" value="<%=MerchantNumber %>"> <input type=hidden name="ReturnURL" value="<%=retURL %>"> <input type=hidden name="Products" value="<%=Products %>">
2
2700
by: BK | last post by:
Can anyone point me to documentation on the firing order for events in a form? Years ago, I programmed in FoxPro and the order was Load, Init, Show, Activate, GotFocus (LISA G was the acronymn I used). Anyone have any links to what order is used in .NET? Thanks,
2
2846
by: APA | last post by:
Why does adding code to the form submit function using the RegisterOnSubmitStatement method prevent the server side event handler for the submit button from firing? This is completely useless. I need some custom javascript validation on form submit but why does is kill the submit button event handler? Submit buttons don't use __doPostBack so what is being effected?
3
5514
by: Jay | last post by:
I am on the 2.0 framework and have run the c:\windows\microsoft.net \framework\v1.1.4322\aspnet_regiis.exe -c and had no success. About half of the buttons on my webforms are firing and the other half are not, primarily anything on the Master is firing but those in the content pane are not. This was working fine yesterday!! I've reviewed all the code changes and can't seem to find a culprit. Here's one example of what I'm trying to...
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.