Click to See Complete Forum and Search --> : incremental doc number save function


alvamgag
06-03-2003, 04:05 PM
Hi All,

I hope someone can help. I know my title sounds
a little confusing, but I will try and explain.

I've created a html form called CPIInfo.html. I would like this form to have a 5 digit number. What I am trying to achieve is the following. And please let me know if this is NOT possible. I would like to have a "SAVE" button on this form. Once you filled in the form and press save, the form should be saved on the HD with the 5 digit number as the document name with extension html. Example, If the first form starts with 10001 as the first 5 digit number, I fill in the form, press SAVE and the form should be saved on the HD as "10001.html". The original CPIInfo.html form will at the same time be reset, but the 5 digit number is now 10002. When it is saved again, it will be saved as 10002.html and the original CPIInfo.html form will at the same time be reset again.

Can this be accomplished by adding a script in the actual CPIInfo.html form or do I need a CGI script?

I apologies for being so long winded, but I hope
someone can help. Again, please let me know if I'm out to lunch on this one.

Thanks for your help.

/alva

Gollum
06-03-2003, 04:33 PM
'Fraid not.

Security restrictions forbid you from having any write access to the user's hard disk.

Khalid Ali
06-03-2003, 04:37 PM
First of all JavaScript itself does not have any ability to make changes on the hard drive of any client machine.It sounds like you need server side coding.
E.g
press a button "Save" and al of the form info is sent to server side processing where is saved as 10001.html page and the it keeps cound of files and the next time around a file is being saved it increments the number....

alvamgag
06-03-2003, 04:38 PM
O.K. Lets say I am the user and it's my HD. What I mean is that I will be using the form on one PC where poeple will go and fill in the form.

Khalid Ali
06-03-2003, 04:43 PM
As I said..javaScript is not equipped to do such task at all..

Choices...jsp,servlets,asp,php...etc.

alvamgag
06-04-2003, 08:36 AM
Hi Khalid,

Thanks for your help. So my understanding here is that I need some sort of cgi script. Am I correct. If so, does anyone one know of any available?

Again, thanks to all.

Khalid Ali
06-04-2003, 08:41 AM
There is a php forum on this site...I bet some one will show you the way..:-)

Charles
06-04-2003, 09:45 AM
#!user/local/bin/perl
use strict;
use CGI qw(:standard start_dl end_dl);
use CGI::Carp qw(fatalsToBrowser);

#create the file

my @files = sort grep {m/^\d*\.html$/} <*.html>;
my $lastFile = pop @files;
$lastFile = '10000.html' unless ($lastFile);

$lastFile =~ m/(\d+)/;
my $fileNumber = $1;
$fileNumber++;

open FILE, ">$fileNumber.html" or die "Cannot open File";
my @names = param;

print FILE start_html ('Values'), h1('Values'), start_dl;
print FILE dt($_).dd(param($_)) foreach (@names);
print FILE end_dl, end_html;
close FILE;

# Send the redirect

my $url = self_url;
my $script = script_name();
$url =~ s/$script.+$/\/$fileNumber.html/;
print redirect ($url);

alvamgag
06-04-2003, 11:44 AM
Thanks a million for the cgi script Charles.
I will try it out. I guess the only thing left
for me to do is to name this script and add it
to my html file to have it called up when the
"SAVE" button is pressed. Correct, or am I missing
something. As you can see, I a little new at this.

Again, Thank-you all.:)

Charles
06-04-2003, 12:57 PM
That script requires a good bit of tweaking but it's all specific to your server. You'll have to talk to your srever folks to get it up and running.

alvamgag
06-04-2003, 03:08 PM
Thanks Charles. I understand. Both the html and the cgi script will be loaded on the HD of a PC, where people will take turns to fill out the form. I guess I now need to add the cgi file name to the html file and the directory information to the cgi script. As I said before, this is all new to me.
I appreciate the help.