473,503 Members | 3,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript events with file input

Plater
7,872 Recognized Expert Expert
I am having a spot of trouble with a little situation.
I want to make the submit invisible on a submit so that the user cannot keep clicking on it while the server is receiving the file transfer.
The webpage will change after the submission, so un-hiding of the button should not be an issuse. Or so I thought.

Given a rough puesdo code of:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <script type="text/javascript>
  4. function HideMe()
  5. {
  6.    document.getElementById("mysubmit").style.visibility="hidden";
  7.    document.getElementById("coversheet").style.visibility="visible";
  8. }
  9. </script>
  10.  
  11. <form>
  12. <input type="file" id="myfile" />
  13. <br/>
  14. <input type="submit" id="mysubmit" onclick="HideMe()">
  15. <span id="coversheet" style="visibility:hidden;">Please wait...</span>
  16. </form>
  17.  
  18.  
  19.  
Now this works great, as long as the form submits.
However, if you consider that a user can enter "sdgrthkzujhsfg" into the file upload textbox and click submit, we run into the problem.
The javascript onclick fires and changes the visibility of the two objects, BUT it never actually makes a page submission because "sdgrthkzujhsfg" is inccorect? (Note: "c:\sdgrthkzujhsfg" triggers a submission with roughly the same as "no file") So the user is left with no submission button and a "please wait...", even though the website is not doing any processing.

I have also tried the OnSubmit() event with the same result.
I found success(for the most part) with onbeforeunload() on the body element, but as I understand it there is some standards issues between browsers?
I tried using the onunload() event but you never see the result (the visibility does not change)

Can anyone recomend anything to only hide the submit button when a submit is actually going to happen? And not when their is the "sdgrthkzujhsfg" type situation?
Nov 17 '08 #1
3 2393
rnd me
427 Recognized Expert Contributor
why don't you simply unhide it when the page loads, in an onload event.

it wont hurt anything to unhide an already visible tag...
Nov 18 '08 #2
Plater
7,872 Recognized Expert Expert
why don't you simply unhide it when the page loads, in an onload event.

it wont hurt anything to unhide an already visible tag...
The page doesn't reload with "sdfgtryhryh" in the file input, it just doesn't do anything. Except fire all the javascript events like it WOULD do something
Nov 18 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
You could try a hidden file upload. If it fails or times out, make the element visible again.

Note that you wouldn't have this problem in Firefox 3 because the file input field is read-and-click-only.
Nov 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
4635
by: Phil Powell | last post by:
I am producing a form using PHP on the back end and Javascript on the front end. The resulting script will come to the browser as follows: <script> <!-- function selectAll() { moveElement =...
3
2669
by: Don | last post by:
How do I code the following Javascript to run in a PHP script? ------------------------- <script type="text/javascript" language="javascript"> // function passfile1path() { var path =...
7
1956
by: Trvl Orm | last post by:
I am working with 2 frames, Left and Right and the main code is in the left frame, which has been attached. Can someone please help me with this code. I am new to JavaScript and can't figure it...
14
5420
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
14
3281
by: horos | last post by:
hey all, I'm a heavy perl user, not so much a java script user, and was wondering... perl has an extremely nice utility called Data::Dumper, which allows you to dump out the contents of an...
24
6285
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
2
2089
by: Safalra | last post by:
Recently I've rewritten much of my old Javascript code to use DOM functions so that enhancements can be attached to documents without needing to alter the HTML code. I assumed that adding event...
19
2179
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? ...
1
3427
by: swethak | last post by:
hi, i have a code to disply the calendar and add events to that. It works fine.But my requirement is to i have to disply a weekly and daily calendar.Any body plz suggest that what modifications i...
0
7192
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,...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6974
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...
0
4665
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...
0
3158
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...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
721
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.