473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help needed with form submits and Perl handling

Hi all, I could use some help programming on of my Perl script to handle
different submit buttons within the same form. Here is what I have so far.

A user goes to a Web form and inputs some data into a textarea box. Below
this box there are two buttons ... one that is labelled "Save & Exit" and
other that is labelled "Save and Preview" On submit of either button, the
form data is sent to the same perl script. What I need to have happen is
have the script detect which button was pressed and that the needed action.
If the Save and Exit button was pressed, the script would write the data to
my database then exit using the Print Location command ... if the Save and
Preview button was pressed, the script would write the data to my database
then display it. What coding would I need at the top of the script that
would somehow determine what button was pressed, and in turn, take the
correct action. If you can help, please add some code examples. Thankx!

RV
Jul 19 '05 #1
1 1941
Robert,

I don't know if this is a good approach, but have you tried something like:

sample.cgi

#!c:\perl\bin\perl
use CGI;

my $q = CGI::new;

my $button1 = $q->param('myButton');

print $q->header,$q->start_html;

if ($button1 =~ /Preview/) {
<--- Save and preview code --->
}

elsif ($button1 =~ /Exit/) {
<--- Save and Exit code --->
}

<form method="POST" action="sample.cgi>
.........
.........
<input name="myButton" type="submit" value="Save and Preview" />
<input name="myButton" type="submit" value="Save and Exit" />
</form>

Hope that helps,
Jeremy Fluhmann
McLane Information Systems

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. ...
3
by: % =joe % | last post by:
I cannot get this code to work. Very simple...I have three list menus. I want to do a check before the form submits to make sure that the value of the 3 fields is equal to 12. Here's my...
4
by: javascript_noob12 | last post by:
Hi. I am trying to create a CGI script that will use Perl to read a text file to get a list of values, then turn that list into a menu on a website. The menu will be a form with a JavaScript...
5
by: Larry | last post by:
I have a form that submits some js created data through a formmail script. One field of the form is a text box for the person's name. I'd like the subject line of the resulting email to be "Some...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Esa | last post by:
Hi, I'm having problems with one strange web system where submitting an application and making queries about its handling status require a series of form submits and response parsing - all in...
6
by: brettev | last post by:
World, I work at a university where the professors have a system to input grades for assignments and calculate final grades, which is output to an excel file. they are then required to get on a...
6
by: Stanimir Stamenkov | last post by:
I have a form without a submit button like: <form name="form1" action="" onsubmit="alert('submit ' + this.name);"> <div> <label>Field 1: <input type="text" name="field1"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.