Solved

Infinite Form does not refresh

Posted on 2000-03-07
6
203 Views
Last Modified: 2013-12-25
I am using a perl cgi script that does basically this:

main
{
    if (param)
   {
        process_form();
   }
    else
   {
        print_form();  
   }
}

At the end of process_form(), there is a call to print_form(), so that
I am basically having an infinite "form loop".

process_form() updates an INI file, in which there is a parameter read and
printed on the page by print_form().

So, let's say that I have submitted the first time and that this INI file
is updated.
I actually see that the parameter is changed when print_form() prints
the page: this is fine.

The problem is: print_form() also sets the default values of the form entries
by reading from this same updated INI, but the changes do not appear on
the newly displayed page.
To make them appear, I have to reload the page completely ("completely" means: not a straight reload, because there is this well-known Repost From Data box that pops up - I need to reopen the document by typing the URL, and THEN reoad by pressing the refresh button).

I tried to include a Javascript document.reload() function at the onSubmit event, but it did not help.

Does anybody have some advice to solve this problem?

Is the only solution to have the process_form() function write a second
page, this page having a Meta-Refresh tag to reload the first document?

Thanks for any hint!
0
Comment
Question by:gaggio
  • 3
  • 3
6 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 2596164
i would suggest restructuring your program as follows...


main {

  if (param){
    process_form();
  }
   print_form();  

}

That way for the 1st time ONLY the form is printed. Every time after that the process_form is done & then the form is printed.

Additionally, add the following META tag in the HTML HEAD tag.

 <HEAD>
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="expires" content="0">
  </HEAD>


Although this is not totally reliable (some problems in IE) it might still help you in a lot of other cases.
0
 
LVL 1

Author Comment

by:gaggio
ID: 2596494
Thanks for your help.

I tried exactly what you said, but it
does not help. Moreover, it writes
the form a second time below the first
form, so that you end up with an infinite number of forms!
(and the second form is exactly the same as the first one: it is NOT updated)

0
 
LVL 16

Expert Comment

by:maneshr
ID: 2596754
are you calling print_form from within process_form??

if so then you need to remove it from process_form.

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 16

Accepted Solution

by:
maneshr earned 20 total points
ID: 2596778
can you send your exact code to this forum?

it will help a lot, Thanks
0
 
LVL 1

Author Comment

by:gaggio
ID: 2596954
Thanks, maneshr
Yes, I was still calling it from
within print_form()
But I found a way to fix the problem:
instead of assigning the values to the
form entries while printing them
(e.g print textfield("myname","myvalue"), I do: param("name","value") right before printing,
and replace the print by print textfield("name").

This fixes the problem completely!
0
 
LVL 1

Author Comment

by:gaggio
ID: 2596972
I'm pretty sure that by removing the print_form() call from process_form(), it would not have solved the problem, because without removing it I was getting twice the EXACT SAME form: no update at all!

Ok, but you deserve the points, since you were the only person replying to me, and I want to close the question right now.

Thanks for trying to help
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

803 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