Solved

Refresh having a Form with Post

Posted on 1998-08-19
9
214 Views
Last Modified: 2010-04-09
Hi
I have a html-doc that I want to refresh every n seconds.
I know how to do that whit the
<meta hhtp-equiv="refresh" content="n">
but my problems is that I use a Form with method=post
and then the reader(IE4 or netscape) ask the user
if he want to repost data.
How do I do so the reader doesn't come up with
that window every time.
/Pelle
0
Comment
Question by:PerBoman
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836838
Rather than POST use the GET method... You will have the ugly URL string, but the info will not have to be "reposted"
0
 

Author Comment

by:PerBoman
ID: 1836839
I don't want to use GET becuse I have Made a cgi program
on the server that retrive info by the POST command.

 
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1836840
Why don't you write the program to parse the query string and do it that way?  Otherwise, you will always get that message...

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:Trevor013097
ID: 1836841
PerBoman,

Matt is right.  You should write your CGI so that it parses whatever you send it and therefore can handle both POSt and GET methods. There are plenty of scripts which are available which will do just that (just look at some of the scripts on Matt's Script Archive under PERL).  The lines needed to do this aren't all the long (about 10 if my memory serves me right).

Your other option if you have to use POST would be to have a Javascript handle the form submission.  Your form would then called a Javascript function onSubmit.  The function would then after a timeout submit your form.  This would then be a resubmission rather than a refresh (ultimately with the same effect) and so IE and NN wouldn't give you the prompt message.

Hope that helps a little.

Trevor.


0
 
LVL 2

Expert Comment

by:bernfarr
ID: 1836842
Don't forget the data limitation on GET methods. If you have large amounts of data coming in on the form, you must use POST.
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1836843
That is very true, which is much of the reason we all started using POST, so maybe the POST method is the better to stick with.  Which means that the Javascript might be the way to go then.

Trevor.


0
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 50 total points
ID: 1836844
PerBoman,

I have written a small script which can resubmit your form without giving the prompt. You can change the amount of time between submits by changing the value (in milliseconds) in the setTimeout line. Here is the script:

<HTML>
<HEAD>
<TITLE>Resubmitting Javascript Form</TITLE>
<SCRIPT LANGUAGE="Javascript">
<!--

function formSubmit() {
  if (document.myForm.stopForm.checked != true) {
      document.myForm.submit();
      setTimeout("formSubmit();", 1000);  // form submits after 1 second (1000 milliseconds)
  }
}

//-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#FFFFFF">

<FORM NAME="myForm" METHOD="POST" ACTION="http://www.someserver.com/somescript.pl">
<B>myField1</B> <INPUT TYPE="TEXT" NAME="myField1" SIZE="20"><BR>
<B>myField2</B> <INPUT TYPE="TEXT" NAME="myField2" SIZE="20"><BR>
<B>myField3</B> <INPUT TYPE="TEXT" NAME="myField3" SIZE="20"> <INPUT TYPE="checkbox" NAME="stopForm"> Check box to stop form submitting after this time<BR>
     <INPUT TYPE="BUTTON" NAME="SubmitButton" VALUE="Send the Form" onClick="formSubmit();">
<INPUT TYPE="RESET" NAME="ResetButton" VALUE="Clear the Form">
</FORM>

</BODY>
</HTML>

If you have a problems please let me know.

Trevor.


0
 

Author Comment

by:PerBoman
ID: 1836845
Thank you for telling me about the method form.submit()

0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1836846
Glad to be of help.

Trevor.


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

808 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