Solved

Redisplaying form after submit error

Posted on 1998-02-17
8
236 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
Comment Utility
What do you use to write your cgi with?
Information on that will be useful.
0
 

Author Comment

by:bgodden
Comment Utility
Bumping up the points...
0
 

Author Comment

by:bgodden
Comment Utility
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
 
LVL 5

Expert Comment

by:julio011597
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:bgodden
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now