Solved

Infinite Form does not refresh

Posted on 2000-03-07
6
194 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
Comment Utility
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
Comment Utility
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
Comment Utility
are you calling print_form from within process_form??

if so then you need to remove it from process_form.

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 16

Accepted Solution

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

it will help a lot, Thanks
0
 
LVL 1

Author Comment

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

743 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

16 Experts available now in Live!

Get 1:1 Help Now