Solved

Redisplaying form after submit error

Posted on 1998-02-17
8
239 Views
Last Modified: 2013-12-25
Hi(sorry for the novel),
Currently my CGI displays an error message when there is an incorrect value submitted in the form and then asks the user to go back and enter the correct information into the form.  This doesn't always work well with certain browsers.  I would like to re-display the form below my error message and ensure that the fields they filled in are still there.

I thought of using the array of values obtained from the submittion and setting the form values to those values, but I have one sticky limitation: I have designed the cgi so that many areas of our website can use it and so that the various areas can customize a section that contains radio buttons for category selection.  To remain this flexible, I would have to capture that section from the submitting page and rewrite, setting the user-checked value to checked...

Is there a simpler way to redisplay the form with it's current values, including the appropriate error message, without have to go through these hoops?
Thanks for any help...
0
Comment
Question by:bgodden
8 Comments
 
LVL 3

Expert Comment

by:slok
ID: 1832017
What do you use to write your cgi with?
Information on that will be useful.
0
 

Author Comment

by:bgodden
ID: 1832018
Bumping up the points...
0
 

Author Comment

by:bgodden
ID: 1832019
Oops, didn't see the comment.  The cgi is written in perl, currently the error page is in a subroutine which is called by the input data verification subroutine and is passed the specific error message, then the page is output form there...
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 5

Expert Comment

by:julio011597
ID: 1832020
Make your script output lines like:

print "<INPUT TYPE="radio" ... CHECKED>";

This way your radio button will be showd selected.

The same method works for checkboxes.

Regards, julio
0
 

Author Comment

by:bgodden
ID: 1832021
Well,  My situation is a little more dynamic then that, I allow publishers from various areas of the site to customize their own radio buttons so I will need to capture the submitting page and suck their radio button section off that page, then output the correct one of that set that has been checked as julio has mentioned above...  Does anyone know of a simpler way to approach this?
Thanks for your response julio...Brian
0
 
LVL 5

Expert Comment

by:icd
ID: 1832022
I don't know if this is of any help to you, but it is what I do in similar circumstances.

I arrange matters so that the script that carries out the validation process (e.g. script.pl) will also draw the input form. The script therefore has three main sections.

1. The first time in, it creates default values for the various form entries (e.g. by reading data from a file or by giving null values). It then displays the form.

2. Every time it detects an error it prints the error message at the top of the page. It then displays the form using the values passed to it from stage 1.

3. When there are no errors it finally processes the data and gives a confirmation text, obviously in this case it does not re-display the form.

The script can detect the difference between the first time in and cases 2 and 3 by looking at the value returned from the submit button.

I handle radio buttons by defining them in the following way.
(Section of my code follows).

$period = $in{period}; # input previous radio state
$period = "W" unless $period; # Give default radio value
eval "\$period$period = \"CHECKED\"";
# some code omitted for clarity

print <<__STATS_END__;
# some code omitted for clarity
<input type="radio" name="period" $periodW value="W">week<br>
<input type="radio" name="period" $periodY value="Y">year<br>
# some code omitted for clarity
__STATS_END__

Now you don't state how the 'customization' by your customers is achieved so I don't know if this approach would be suitable for you.

0
 

Author Comment

by:bgodden
ID: 1832023
icd,  thanks for your input.  I've already rolled out a different version of this that mainly works with separate files, i.e. each area has it's own feedback.html form page and it's own success.html confirmatiuon page.  This was to allow them to make cosmetic and content changes, including the different radio buttons, which in my script I simply look for $FEEDBACK{"type"}, then tag their subect field with the type specified.  It looks like I'm going to need to capture the submitting page when data is submitted so that I can redisplay their radio buttons in the event of an error...
0
 

Accepted Solution

by:
delvin earned 250 total points
ID: 1832024
What about using a javascript to place a button on the error page that allows the user to go back to the original form, with the curent values, and type in the necessary information.  It would simulate pressing the "back" button on the browser.  It would not display the error message, but since the person already seen the message they know what fields were missed, or what they did wrong.

Your javascript can even be palced directely in the <input> tage:

<Input Type=Button Value="Correct Form" onClick="location.back()">

Just an idea.  Does the error screen being on the screen add that much value to the site?


0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to Modify a Script I found 5 108
issue with beginner powershell script. 5 68
Need to combine two scripts 2 33
IDE for Python 5 23
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question