delayed display of a field button

D

DL

I have a form like this:
<html>
<body onload("save(), otherFunction()")>
<form>
name: <input ..../>
email <input .../>
comment: <textarea ....></textarea>
save: <input type="submit" id="saveit" value="SAVE"
style="display=none">
</body>
</html>

What I'd like to do is:
when the form is first loaded, hide the SAVE input box, after 40
seconds show it up.

I have a function like
function save() {
setTimeout('docuemnt.getElementById
("saveit").style.display="block"',4000);
}

Not working. Know why?

Thanks.
P.S. Not putting the js code directly in the onload event trigger at
BODY tag is because there are other js functions at the tag level as
well.
 
S

SAM

Le 8/19/09 9:32 PM, DL a écrit :
I have a form like this:
<html>
<body onload("save(), otherFunction()")>
<form>
name: <input ..../>
email <input .../>
comment: <textarea ....></textarea>
save: <input type="submit" id="saveit" value="SAVE"
style="display=none">

Do you code only for IE ?
It is :
save: <input type="submit" id="saveit" value="SAVE"
style="display:none">
</body>
</html>

What I'd like to do is:
when the form is first loaded, hide the SAVE input box, after 40
seconds show it up.

I have a function like
function save() {
setTimeout('docuemnt.getElementById
("saveit").style.display="block"',4000);
}

function save() {
setTimeout('document.getElementById("saveit").style.display="block"',4000);
}

Not working. Know why?

There is no reason for me, except: docuemnt <-> document .

Maybe better :

function save() {
setTimeout( function()
{document.getElementById((saveit().style.display='block';},4000);
}


The next question : an 'input' is it a 'block' ?
Wouldn't it be better : display='inline' ?

It is a very bad idea to expect JS will show the submit button.
Prefer to hide it by JS and show it as well.
(the html page or form must to work without JS)
 
D

Don84

Le 8/19/09 9:32 PM, DL a écrit :


Do you code only for IE ?
It is :
save: <input type="submit" id="saveit" value="SAVE"
style="display:none">




function save() {
setTimeout('document.getElementById("saveit").style.display="block"',4000);

}

There is no reason for me, except: docuemnt <-> document .

Maybe better :

function save() {
setTimeout( function()
{document.getElementById((saveit().style.display='block';},4000);

}

The next question : an 'input' is it a 'block' ?
Wouldn't it be better : display='inline' ?

It is a very bad idea to expect JS will show the submit button.
Prefer to hide it by JS and show it as well.
(the html page or form must to work without JS)

of
{document.getElementById((saveit().style.display='block';},4000);
where's the saveit() function?

"It is a very bad idea to expect JS will show the submit button"
The reason for doing this is that 3000ms after the form is loaded data
would automatically be saved (working fine), now I don't want some
user, just for the heck of it, click on Save before the 3000ms, and
that's the reason why I'd like the 'Save' button initially not to
show.

Sorry for the typo.
 
S

SAM

Le 8/19/09 11:53 PM, Don84 a écrit :
of
{document.getElementById((saveit().style.display='block';},4000);
where's the saveit() function?

was a typo
corrected in my next post

Next post that I don't see here ... what does my FAI ?

typo corrected :

function save() {
setTimeout( function()
{document.getElementById('saveit('.style.display='block';},4000);
}

Hope this time posting runs faster.
"It is a very bad idea to expect JS will show the submit button"
The reason for doing this is that 3000ms after the form is loaded data
would automatically be saved (working fine), now I don't want some

automatically ? by JS ?
(why that for this automatic save?)
user, just for the heck of it, click on Save before the 3000ms, and
that's the reason why I'd like the 'Save' button initially not to
show.

If the data are saved automatically (by JS) where is the problem to hide
the submit button by JS too ?

Anyway the submit can fires pressing the Enter key in any text-field !!
So your hided button has no importance.
Sorry for the typo.

You'rn't alone ;-)
 
S

SAM

Le 8/20/09 12:16 AM, Thomas 'PointedEars' Lahn a écrit :
DL said:
I have a form like this:
<html>
<body onload("save(), otherFunction()")>
<form>
name: <input ..../>
[...]

Not working. Know why?

Your markup is not Valid. <http://validator.w3.org/>

Ouch !
I din't see it ! :-(

Once more an IE's way of coding ?

<body onload="save(); otherFunction();">
 
S

SAM

Le 8/20/09 12:45 AM, SAM a écrit :
typo corrected :

function save() {
setTimeout( function()
{document.getElementById('saveit('.style.display='block';},4000);
}

Tremendous !

function save() {
setTimeout( function()
{document.getElementById('saveit').style.display='inline';},4000);
}
 
D

Don84

Le 8/20/09 12:45 AM, SAM a écrit :





Tremendous !

function save() {
setTimeout( function()
{document.getElementById('saveit').style.display='inline';},4000);

}

Sorry, it didn't work. Also, this inline editing feature is for IE
only, FF has a hell time with it in terms of layout or my layout is
lousy. Rationale for auto saving, your user is filling a lengthy form
and all that, spending 15, 25 minutes already, quite important stuff,
all of a sudden, fat finger, power outage and what not, the computer
goes bananas...
 
S

SAM

Le 8/20/09 1:25 AM, Don84 a écrit :
Sorry, it didn't work.

Did you correct your body onload ?

Because, that time, that must work :
Also, this inline editing feature is for IE
only, FF has a hell time with it in terms of layout or my layout is
lousy.

???
just IE accepts bad (or approximative) code when other browsers refuse it
Rationale for auto saving, your user is filling a lengthy form
and all that, spending 15, 25 minutes already, quite important stuff,
all of a sudden, fat finger, power outage and what not, the computer
goes bananas...


Heu ... 40 seconds isn't 25 minutes ;-)
 
D

Dr J R Stockton

In comp.lang.javascript message <e905844e-0e66-48f5-be83-2df933fc194d@m2
0g2000vbp.googlegroups.com>, Wed, 19 Aug 2009 12:32:41, DL
What I'd like to do is:
when the form is first loaded, hide the SAVE input box, after 40
seconds show it up.

I have a function like
function save() {
setTimeout('docuemnt.getElementById
("saveit").style.display="block"',4000);
}

To avoid typos, it is NECESSARY that code in a message be copy'n'pasted
from the tested original. It is desirable that, before the article is
released, the code should be copy'n'pasted for re-test.

Code in messages should be executable as posted, which means that it
should be written and tested within your posting margins. Posting must
not break strings, nor do other evils.

You did not say in what manner your code did not work - whether the
button failed to appear at all, or failed to appear after the delay
called for, or what.

You did not say what browser(s) you tested with, not what diagnostics
were visible. For example, in Firefox, the Error Console (FF 3.0.13 :
in Tools; Ctrl-Shift-J) should always be used in testing, unless you
have a better add-on.

You should change the setTimeout string to 'alert(0);' or put that at
its beginning. Then you will know whether the timeout actually fired.

Your text calls for a 40 second delay; your code for 4000 milliseconds.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top