JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 7th, 2001, 02:12 AM
Dups Dups is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 30 Dups User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Unhappy Javascript problem

Hello there.....

I am trying to produce an application where the user
will be able to specify the file in the server where he
want to store some data. Now if the user selects an
existing file, the cgi at the server should be able to detect
that and should give the user a warning message.

Now I am doing the thing in the following way.
When the user writes the name of the file and
submits the form, the cgi script in perl detects
whether it is an existing one and sends a
confirm('overwrite') if the file exists already.
Depending on the user's choice to overwrite
or not the form is either submitted or not.

At present I made the confirm dialog box to appear
when the second page was getting loaded using
the onLoad. But then if I use form.submit in the javascript
function, it is not getting submitted because I had not started
the form.
Here is the javascript function that I use on the second page.
function test(form,file,exists)
{
var exists =String(exists);
var file =String(file);
if (exists =='yes')
{
answer =confirm('Overwrite existing file');
answer =String(answer);
if (answer == 'true')
{
form.filename.value =file;
form.overwrite.value ='yes';
form.submit();
}
}
}

Is there a way to solve my problem.
Am I doing things in the right way or is there any other better
way to solve my problem

I have one more doubt. Is it possible to load a page based one
some condition.
Is it possible to call a function when a hidden element in the
form is changed.
Could anyone please help...
Thanks ..
Dups

Last edited by Dups : June 7th, 2001 at 02:18 AM.

Reply With Quote
  #2  
Old June 7th, 2001, 02:44 AM
Void Void is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: The Netherlands
Posts: 200 Void User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to Void
No specific answer

I can't quite understand the problem, but there are a few things I want to comment on:

(correct me if I'm wrong)
1. The onLoad event is triggered after the page has finished loading.
2. The confirm function returns a boolean. No need to convert the result to a string first. Just do: if (confirm(...)) { ... }

Question: how do you know that your submit function does not work? Do you get an error? Have you tried putting an alert right in front of your submit just to see if the code actually gets there?

You also asked:
"Is it possible to call a function when a hidden element in the
form is changed."
It is only possible to change a hidden element through a function. So you are already in a function and you can call any other function you want

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Javascript problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap