Solved

Redisplaying form after submit error

Posted on 1998-02-17
8
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

726 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