
June 7th, 2001, 02:12 AM
|
|
Contributing User
|
|
Join Date: Jan 2001
Posts: 30
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
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.
|