Scruffstone 0 Newbie Poster

Hi there,

I'm trying to write a script that when a user clicks the "save" button it takes the content of a text box, calls another script which writes this to a file. The bit I can't get it to do is recognise that the "save" button has been clicked on. I want it to do this as I want to add other buttons at a later stage.

Below is the code that calls the file

print "<form name=\"page_editor\" METHOD=\"POST\" action=\"/cgi-bin/Process_page_editor_form.pl\">\n\n"; # form action = call a perl file that processes the text, don't do it in this file
display_text_box();
print "\n<br>";
print "<input name=\"input_file_name\" type=\"hidden\" value=\"$INPUT_FILE_NAME\" />";
print "<input name=\"input_filehandle\" type=\"hidden\" value=\"$INPUT_FILEHANDLE\" />";
print "<input name=\"local_text\" type=\"hidden\" value=\"$local_text\" />";

#print "<button type=button onClick=\"button_click(2)\">Save1</button>"; # display a button that runs a sub when clicked
print "<input type=\"submit\" name=\"save\" value=\"Save\">"; # display a button that runs a sub when clicked

And here is the code it's calling. If I print out the value of "input_file_name" it works fine but "name" is blank....

#!/usr/bin/perl

use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use Fcntl qw(:flock);

my $query = new CGI;

print "Content-type: text/html\n\n"; # must send a header first

my $button_value = $query->param('name');
my $input_file_name = $query->param("input_file_name");

Any ideas gratefully received.
cheers
Sarah

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.