how to blank the screen when any submit-type buttons clicked

C

charlie_M

Is there a way to blank the screen in a FORM's onsubmit=... to blank
the screen for the user??

I asked this before and got a way to blank a table by id with

"document.getElementById('tabid').style.display='none';" in the onclick
event and setting the encapsulating table's ID to 'tabid'.

I was wondering if this or some other similar approach that could
possibly be planted globally in my pages in the onsubmit validation
sequence ????
 
C

charlie_M

Can you nest DIVs??

The problem and the reason I ask the original question... these pages
are written in Foxpro and there are literally hundreds of them. I am
loking for the easiest method to blank the screen when sublitted and
would favor the method that would allow trhe change be centrally
applied (like a form's onsubmit()).

TIA
Chuck
 
R

Randy Webb

charlie_M said the following on 10/3/2005 3:45 PM:
Can you nest DIVs??

Yes. What does that have to do with Javascript?
The problem and the reason I ask the original question... these pages
are written in Foxpro and there are literally hundreds of them. I am
loking for the easiest method to blank the screen when sublitted and
would favor the method that would allow trhe change be centrally
applied (like a form's onsubmit()).

If Foxpro is screwing your pages up that bad, you need a new editor.

<form onsubmit="hideTheBody()">

function hideTheBody(){
bodyNode = document.body?document.body:document.documentElement;
bodyNode.innerHTML = '';
}
 
C

charlie_M

Does this allow the form to be submitted?? My initial test shows the
screen blanks.. but the data does not go to the server??


FYI:. Foxpro is not an editor.... also not javascript ;o)) Foxpro is a
fuly compiled language with similarities to Visual Basic and C++ and
the ilk. In this case... Foxpro is generating/interpreting web pages
and serving them through an isapi interface to/from a webserver.
 
R

RobG

Randy said:
charlie_M said the following on 10/3/2005 3:45 PM:



Yes. What does that have to do with Javascript?



If Foxpro is screwing your pages up that bad, you need a new editor.

<form onsubmit="hideTheBody()">

function hideTheBody(){
bodyNode = document.body?document.body:document.documentElement;
bodyNode.innerHTML = '';
}

That doesn't work, by the time the submit runs, there is nothing left to
submit (or was that the intention?).

Try:

function hideTheBody()
{
bodyNode = document.body? document.body : document.documentElement;
if (bodyNode.style){
bodyNode.style.display = 'none';
}
}

However, it seems like a very bad idea - why not just write 'The form is
being submitted' or similar to the page in a faux message dialog?.
 
R

RobG

Dr said:
If you have some sort of global onsubmit function , you most certainly
could blank the screen or just about anything else.

I would broabably not choose display:none , as it confuses some browsers
as relates to the content of the container becomming not only invisible,
but occasionally inacessible to script. perhaps if you simply take the
div with the form in it and adjust the left or top to a location that is
-x and/or -y enough to be off screen.

The following hides just the form, but it could hide the entire body.

There are some usability issues here - what happens if the submit fails?
The user now has a blank page and must work out that they need to
refresh the page rather than navigate 'back' - how is that really any
different to learning that they should only submit once and wait?

If the submit takes a while and the page stays blank, will they hang
around or just go elsewhere and possibly screw-up whatever process they
were engaged in?

Why attempt to teach non-standard behaviour?

Anyhow:

<form ... onsubmit="hideMe(this);">

// Using a shift:
function hideMe(f)
{
f.style.position = 'absolute';
f.style.left = '-9000px';
}


// Using visibility:
function hideMe(f)
{
f.style.visibility = 'hidden';
}
 
R

Randy Webb

RobG said the following on 10/3/2005 9:19 PM:
That doesn't work, by the time the submit runs, there is nothing left to
submit (or was that the intention?).

<g>

I get facetious at times :)
Try:

function hideTheBody()
{
bodyNode = document.body? document.body : document.documentElement;
if (bodyNode.style){
bodyNode.style.display = 'none';
}
}

However, it seems like a very bad idea - why not just write 'The form is
being submitted' or similar to the page in a faux message dialog?.

My personal preference is to let the user screw up. Nothing will teach
you quicker not to double-submit a form than trying to go through email
tech (or the phone) to try to get your money back after making that
screw up.


--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
R

RobG

Randy said:
RobG said the following on 10/3/2005 9:19 PM:
Randy Webb wrote:
[...]
If Foxpro is screwing your pages up that bad, you need a new editor.

<form onsubmit="hideTheBody()">

function hideTheBody(){
bodyNode = document.body?document.body:document.documentElement;
bodyNode.innerHTML = '';
}

That doesn't work, by the time the submit runs, there is nothing left
to submit (or was that the intention?).


<g>

I get facetious at times :)

The 'Foxpro as an editor' bit was something of a giveaway! ;-)

[...]
My personal preference is to let the user screw up. Nothing will teach
you quicker not to double-submit a form than trying to go through email
tech (or the phone) to try to get your money back after making that
screw up.

Yes. I thought issues with multiple submits were fixed years ago on the
server. Client-side scripting is bound to fail sufficiently often that
it can only be considered a convenience some of the time for some users
and certainly not a robust solution.

I get the feeling a course somewhere has a unit on multiple submission
and some of the students have decided to come here...
 
C

charlie_M

RobG said:
Try:

function hideTheBody()
{
bodyNode = document.body? document.body : document.documentElement;
if (bodyNode.style){
bodyNode.style.display = 'none';
}
}
OK.. this solution works for submit buttons. However... it does not
appear to hit the <form onsubmit"....> when the page is submitted by
some of the form's other elements... like 'onclick="submit()"' and
'onchange="submit()"'. Whats up with that??

As for the suggested solution "put up a faux message..." that might
work too. Can it be placed in the center of a screen and will it go
away when the new screen arrives without intervention??


Chas
 
R

Randy Webb

charlie_M said the following on 10/4/2005 10:39 AM:
RobG wrote:



OK.. this solution works for submit buttons. However... it does not
appear to hit the <form onsubmit"....> when the page is submitted by
some of the form's other elements... like 'onclick="submit()"' and
'onchange="submit()"'. Whats up with that??

What is up with that is that you are using the incorrect elements to
cause form submission.

formName.submit() does not fire the onsubmit event handler.
As for the suggested solution "put up a faux message..." that might
work too. Can it be placed in the center of a screen and will it go
away when the new screen arrives without intervention??

Try it and see.......
 
C

charlie_M

Randy said:
What is up with that is that you are using the incorrect elements to
cause form submission.

formName.submit() does not fire the onsubmit event handler.

That one fact is very disapointing. I feel I am not using 'incorrect'
elements but I am let down with the fact that they don't fire through
the form''s onsubmit. I wonder what the thinking was??? Why not?

I did put this solution in a global onsubmit handler.... but now I
guess I need to add the call to 'hideTheBox()' in each and every
'onclick=' and 'onchange=' phrase in-use on the application website....
Oh well ;o))

My thanks to everyone who tried to help me with this.

Chas
 
R

Randy Webb

charlie_M said the following on 10/4/2005 3:02 PM:
That one fact is very disapointing. I feel I am not using 'incorrect'
elements but I am let down with the fact that they don't fire through
the form''s onsubmit. I wonder what the thinking was??? Why not?

The only element in HTML whose purpose is to submit a form is an <input
type="submit">. Anything else that is used to submit or cause a form to
be submitted is incorrect use of the element. Form elements have
intended uses and to use them for anything else is incorrect usage.
I did put this solution in a global onsubmit handler.... but now I
guess I need to add the call to 'hideTheBox()' in each and every
'onclick=' and 'onchange=' phrase in-use on the application website....
Oh well ;o))

How does your form get submitted if JS is disabled? And, if your users
are too lazy to click a Submit button, how would they ever conjure up
the energy to click it twice?
 
C

charlie_M

Randy said:
The only element in HTML whose purpose is to submit a form is an <input
type="submit">. Anything else that is used to submit or cause a form to
be submitted is incorrect use of the element. Form elements have
intended uses and to use them for anything else is incorrect usage.

Thanks for clearing that up... but I would have hoped that js's
submit() would have tried to emulate this behavior?!?
How does your form get submitted if JS is disabled? And, if your users
are too lazy to click a Submit button, how would they ever conjure up
the energy to click it twice?
This is a monsterous application for clients. We (IT) get to specify
browser(s) and feature(s) in order to serve their purposes. JS=true is
just one of the specs.

As for the lazy users.. typically they double-click an element and the
way the system accesses the massive files it deals with .... it takes
sometimes 2-3 seconds to respond to a query... and the system races to
catch the subsequent clicks and bypass them. A great many of the pages
do not even have a submit button......... action taking place onclick
and onchange.

Chas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top