Solved

Infinite Form does not refresh

Posted on 2000-03-07
6
205 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
[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
  • 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AWS CLI - Instances, Volumes & Tagging 2 133
Powercli + List all VM's Per SCSILUN 15 119
Powershell Code 3 42
Deploy restore partition 1 23
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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 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 …
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.

740 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