Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing to a .txt file

Status
Not open for further replies.

mackey333

Technical User
May 10, 2001
563
0
0
US
what i am trying to do is pretty hard to explain so here is a simplified example of the problem:

i need to clear a text file, write to it, and then be able to read from it...so say someone puts there name in a text box and hits submit, the current stuff in the text file is cleared, the new name is writen to it, and then it is saved (kind of like a server side cookie)...then on a different page, i need to somehow get the text into a javascript variable...i relieze this would probably be easier with a database, but i am on a free server that doesnt support them...i'm guessing there should be a jscript or vb way to do this...thanks for any help... -Greg :-Q

flaga.gif
 
hi Greg
write to files? on client? do you think it's possible without some warning to the user about security violations?

that server doesn't support ANY server side language?

i think it might be done in vbscript, but i'm not vb..~er :) Victor
 
Greg

If the server allows you to run CGI scripts, then you could use a script to dynamically create the Javascript and HTML for a page. Example:

Code:
#!perl
use CGI qw( :all );
use CGI::Carp qw( fatalsToBrowser );

my $foo = param( 'foo' );

my $javascript = qq[
    var dynamicValue = "$foo";
];

print header;
print start_html( -script => $javascript, -onLoad => "alert( dynamicValue )" );
print end_html;

As for the original form, you would have an input button with name property of 'foo', and the form 'action' should point to the CGI script. Note that you can write a more complicated version of the above script that acts as the empty form, as well as the filled one.

Hope this helps, Neil ;-)
 
well i can do cgi's..but i dont rly understand them..how would i write to the txt file then? -Greg :-Q

flaga.gif
 
take a look at this, Greg
thread452-133643
(how to create a file on server)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top